android - SharedPreferences int not updated after apply -



android - SharedPreferences int not updated after apply -

i running:

int value = mpreferences.getint(key, 0); mpreferences.edit().putint(key, value+1).apply(); int newvalue = homecoming mpreferences.getint(key, 0);

however same result value , newvalue. updated result appears when phone call getint() later in code. thought updates sharedpreferences object using apply() instantly visible in sharedpreferences object. not case?

if want synchronous update have utilize

commit()

http://developer.android.com/reference/android/content/sharedpreferences.editor.html#commit()

android sharedpreferences

Comments

Popular posts from this blog

maven fortify plugin : Unable to load build session with ID XXXXX .. See log file for more details -

c# - Primavera WebServices does not return any data -

android - Display emoji panel with genymotion - keyboard/touch input? -