Saturday 15 August 2015

android - SharedPreferences overwrite other value -


I have a problem with sharedPreferences if I want to save two different values. Tried with code: Shared shared references = refresh = getSherlockActivity (). GetPreferences (reference.MODE_PRIVATE); SharedPreferences.Editor Editor = sharePref.edit (); Editor.putInt (GetString (R. String. Saved), hr); Editor.commit (); Editor.putInt (getString (R.St.SavedStartSilentMinute), minimum); Editor.commit (); // is an editor.commit () enough

If I run this code, the first value is overwritten with the seccond value. Why is it that if Delta has been saved correctly in the second part?

Your code looks correct!

You can make it easier by making all the stuff after "putting" all operations but I do not think this may be your problem ...

Just make sure The defined values ​​of SavedStartSilentHour and SavedStartSilentMinutes xml are correctly defined, that is, if they are similar to the course, they will be overwritten. (This is the only thing that matters to me considering your code).

Learn about your progress;)

No comments:

Post a Comment