android - SharedPreferences not saving values properly -
I'm trying to save a string to share preferences. The way I tried to do it is :
EyeshireFranspace_prefs = PreferenceManager.GetDefaultSharedPreferences (this); ISAprotection Editor _Editor = _prefs.Edit (); _editor.PutString ("myString", "123"); _editor.Commit (); Next I try to print my string:
_txtView.Text = _prefs.GetString ("mystring", "string can not be found is" ); When I run the application, my textview correctly prints "123" then everything is working as a purpose; The issue of shared preferences is that it is consistent so if I now try to comment on the following two rows:
_editor.PutString ("mystring", "123"); _editor.Commit (); Then again, my text view "String can not be found" displays. So the string is not being saved for any reason? Does anyone see why this is?
However, the shared preferences are That it is constantly : it is consistent between app spans when you exclude the code and launch again, then you have not created any refreshing app There are no default stored preferences, this is the reason why it is not working when you comment on it. If you want to store it only once in shared preferences, then you should check whether the app is first or not, and then if true < / Em>, store in shared priorities.
Comments
Post a Comment