运行时共享首选项是否存储在内存中? [英] Are shared preferences stored in memory during runtime?

查看:49
本文介绍了运行时共享首选项是否存储在内存中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Android 中的共享首选项是否总是在启动时读取并在运行时存储在内存中?如果没有,还有比这更有效的阅读偏好的方法吗?

Are shared preferences in Android always read at startup and stored in memory during runtime? If not, are there more efficient ways to read preferences than this?

settings = getSharedPreferences("myPrefsFile", 0);
int answer = settings.getInt("ULTIMATE_QUESTION", 42);

推荐答案

Android 中的共享首选项是否始终在启动时读取并在运行时存储在内存中

简单地是,直到用户没有从设置中手动清除它.

Simply Yes till user doesn't clear it manually from setting.

还有比这更有效的阅读偏好的方法

正如 JonasCz 在评论中所说的那样.这是迄今为止最常见且对开发人员友好的方式.

As JonasCz said in comments.. this is the most common and developer friendly way till now.

这篇关于运行时共享首选项是否存储在内存中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆