java - Saving variable through app shutdown in android -


this question has answer here:

i want save variable through application shutdown. have heard sharedpreferences, didn't understand it. isn't there easier way store 1 variable. detailed explanation great, still beginning.

try saving shared preferences:

    sharedpreferences sharedpreferences = preferencemanager.getdefaultsharedpreferences(getapplicationcontext());     sharedpreferences.edit().putstring("key","value").apply(); 

for getting shared preferences value:

    sharedpreferences sharedpreferences = preferencemanager.getdefaultsharedpreferences(getapplicationcontext());     sharedpreferences.getstring("key",""); 

i hope help.


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -