List of utility methods to do SharedPreferences Save
void | putPrefs(Activity context, int mode, Map Purpose - Put preferences through the Shared Preferences API. SharedPreferences prefs = context.getPreferences(mode); if (pairs != null && !pairs.isEmpty()) { SharedPreferences.Editor editor = prefs.edit(); for (Entry<String, String> pair : pairs.entrySet()) { editor.putString(pair.getKey(), pair.getValue()); editor.commit(); |
void | putSharedPrefs(Context context, String prefName, int mode, Map Purpose - Put shared preferences through the Shared Preferences API. SharedPreferences prefs = context.getSharedPreferences(prefName, mode); if (pairs != null && !pairs.isEmpty()) { SharedPreferences.Editor editor = prefs.edit(); for (Entry<String, String> pair : pairs.entrySet()) { editor.putString(pair.getKey(), pair.getValue()).commit(); editor.commit(); ... |
void | saveSetting(Context context, String name, Long value) save Setting SharedPreferences prefs = context.getSharedPreferences(PREFERENCES, Context.MODE_PRIVATE); prefs.edit().putLong(name, value).apply(); |
void | saveSetting(Context context, String name, String value) save Setting SharedPreferences prefs = context.getSharedPreferences(PREFERENCES, Context.MODE_PRIVATE); prefs.edit().putString(name, value).apply(); |
Object | updatePrefValueByModel(SharedPreferences pref, String key, String thisModel, String targetModel, Object targetModelValue, Object notTargetModelValue) update Pref Value By Model Object value; String mdl = "#" + thisModel.toUpperCase(Locale.US) + "#"; if (targetModel != null && targetModel.indexOf(mdl) != -1) { value = targetModelValue; } else { value = notTargetModelValue; if (value != null) { ... |
void | setSharedPreferences(String key, String value, Context context) set Shared Preferences SharedPreferences prefs = PreferenceManager .getDefaultSharedPreferences(context); SharedPreferences.Editor editor = prefs.edit(); editor.putString(key, value); editor.commit(); |
void | putPrefBoolean(Context c, String key, boolean value) put Pref Boolean SharedPreferences sp = PreferenceManager .getDefaultSharedPreferences(c); sp.edit().putBoolean(key, value).commit(); |
void | putPrefInt(Context c, String key, int value) put Pref Int SharedPreferences sp = PreferenceManager .getDefaultSharedPreferences(c); sp.edit().putInt(key, value).commit(); |