public static final String KEY_MY_PREFERENCE = "my_preference"; int fontsize; public void onCreate(Bundle savedInstanceState) { SharedPreferences prefs = getSharedPreferences("fontsize", MODE_PRIVATE); fontsize = prefs.getInt(KEY_MY_PREFERENCE, fontsize); } protected void onStop() { super.onStop(); SharedPreferences prefs = getSharedPreferences("fontsize", MODE_PRIVATE); SharedPreferences.Editor editor = prefs.edit(); editor.putInt(KEY_MY_PREFERENCE, fontsize); editor.commit(); }
Monday, June 18, 2012
[Android] Save parameter before quit the activity
Save fontsize before finish current activity and call the value when activity is restarted.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment