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
Post a Comment