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

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -