android - whether the permanent value returned by these methods? -
android - whether the permanent value returned by these methods? -
activity.getpreferences(mode)
, sharedpreferences.edit()
can this?
(at activity class):
//... private sharedpreferences pref; private editor editor; oncreate() { pref = getpreferences(activity.mode_private); editor = pref.edit(); } ondestroy() { int somesavedint = pref.getint("someint", 0); editor.putint("someint", somesavedint * 2); } //...
or before utilize should value of pref
, editor
?
you can create static variable of shared preference too. or can each time, both fine.
just maintain in mind have editor.commit();
save/commit these values always.
android
Comments
Post a Comment