Are shared preferences stored in memory during runtime?

此生再无相见时 提交于 2020-01-03 16:42:36

问题


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);

回答1:


Are shared preferences in Android always read at startup and stored in memory during runtime

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

are there more efficient ways to read preferences than this

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



来源:https://stackoverflow.com/questions/29634847/are-shared-preferences-stored-in-memory-during-runtime

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!