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

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -