shared prefrence code example
Example 1: android sharedpreferences
SharedPreferences sharedPref = getSharedPreferences("name", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPref.edit();
editor.putString("key", "Value");
editor.commit();
Example 2: get preference value android
boolean mBoolean = PreferenceManager.getDefaultSharedPreferences(yourContext).getBoolean(key, defaultValue);
Example 3: refresh sharedpreferences going back java
getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
Example 4: set preference value android
boolean committed = PreferenceManager.getDefaultSharedPreferences(yourContext).edit().putBoolean(key, mValue).commit();