java - SharedPreferences is not changing -


i have activity shows simple 2 textviews, , text string array located in class. trying load first string in array when loading, , change next time activity loading change value in textview string after string showed first on textview, , on. change value of sharedprefrences still shows me first string. problem? change value of index of string array, still shows me first string. in advanced.

public class dailymessage extends appcompatactivity {     public sharedpreferences startexplepref; string[] descs; string[] titles; @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_daily_message);     toolbar toolbar = (toolbar) findviewbyid(r.id.toolbar);     setsupportactionbar(toolbar);      string currentdatetimestring = dateformat.getdatetimeinstance().format(new date());     startexplepref = preferencemanager.getdefaultsharedpreferences(this);      boolean isfirstrun = startexplepref.getboolean("firstrun", true);     if (isfirstrun) {         sharedpreferences.editor editor = startexplepref.edit().putboolean("firstrun", false);         editor.commit();         startexplepref.edit().putint("day",0).commit();      }      textview titletv = (textview)findviewbyid(r.id.title);     textview desctv = (textview)findviewbyid(r.id.description);     textview datetv = (textview)findviewbyid(r.id.date);     datetv.settext(currentdatetimestring);      int dayfortitle = startexplepref.getint("day",0);     titletv.settext(dailymessagescontent.content[dayfortitle]);     desctv.settext(dailymessagescontent.content[dayfortitle]);     dayfortitle = dayfortitle++;     startexplepref.edit().putint("day",dayfortitle).commit();  }   } 

this string other class:

public static string content[] = {"test1", "test2","test3"}; 

it's beacause everytime use dayfortitle = dayfortitle++; add variable,but dayfortitle++ return primitive value 0,so need change dayfortitle = dayfortitle++; single dayfortitle++.


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -