Android, How can i set the fragment to display in the activity even closing the app? -
is there way save fragment on change?even after closing app , open again fragment stay there
you can use shared preferences save variables you'll need next time open app. look @ documentation.
protected void ondestroy(){ super.ondestroy(); sharedpreferences sharedpref = getactivity().getpreferences(context.mode_private); sharedpreferences.editor editor = sharedpref.edit(); editor.putint(getstring(r.string.saved_high_score), newhighscore); ... editor.commit(); } protected void oncreate(){ sharedpreferences sharedpref = getactivity().getpreferences(context.mode_private); long highscore = sharedpref.getint(getstring(r.string.saved_high_score), defaultvalue); ... }
Comments
Post a Comment