android - how to save activity's data when we want to close the app or back to other activities -
for example: want enter string in (edit text) , string saved when want close app or return other activities.
for need use sharedpreferences
documentation
first use save it:
sharedpreferences myprefs = this.getsharedpreferences("myprefs", mode_world_readable); sharedpreferences.editor prefseditor = myprefs.edit(); prefseditor.putstring(my_text, edittext.gettext().tostring()); prefseditor.commit();
then when need use again :
sharedpreferences myprefs = this.getsharedpreferences("myprefs", mode_world_readable); string prefedttext = myprefs.getstring(my_text, 0);
Comments
Post a Comment