Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are shared preferences stored in memory during runtime?

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);
like image 517
Krøllebølle Avatar asked Nov 09 '22 16:11

Krøllebølle


1 Answers

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.

like image 68
Ranjit Avatar answered Nov 14 '22 23:11

Ranjit