android - getting Exception on Shared Preferences Store -
i trying save shared preferences using
sharedpreferences sharedpref = getsharedpreferences("bluefreesharedpreferences",0); preferencemanager.getdefaultsharedpreferences(getapplicationcontext()); prefeditor = sharedpref .edit(); prefeditor.putstring("username", username); prefeditor.putstring("password", password); prefeditor.commit();
on samsung galaxy 1900 2.2.1 not saving shared preferences on emulator 2.2.1 , htc y 1 4.0.3 os working fine. read post here http://code.google.com/p/android/issues/detail?id=14359 can guide me still issue?
i don't think you've initialized editor right, here's little code i've written while ago, makes preference of counter , increments upon execution
sharedpreferences counter = getsharedpreferences("prefs", context.mode_private); sharedpreferences.editor count_editor = counter.edit(); int currentcount = counter.getint(packagename +"", 0); currentcount++; count_editor.putint("times clicked", currentcount); count_editor.commit();
try http://developer.android.com/guide/topics/data/data-storage.html#pref
Comments
Post a Comment