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

cookies - Yii2 Advanced - Share session between frontend and mainsite (duplicate of frontend for www) -

angular - password and confirm password field validation angular2 reactive forms -

php - Permission denied. Laravel linux server -