Android Utililty Methods SharedPreferences Get

List of utility methods to do SharedPreferences Get

Description

The list of methods to do SharedPreferences Get are organized into topic(s).

Method

BooleangetPrefBoolean(SharedPreferences pref, String key)
get Pref Boolean
Object value = getPrefObject(pref, key);
return value != null ? (Boolean) value : null;
BooleangetPrefBoolean(SharedPreferences pref, String key)
get Pref Boolean
Object value = getPrefObject(pref, key);
return value != null ? (Boolean) value : null;
intgetPrefInt(SharedPreferences pref, String key, String default_value)
get Pref Int
int ret = getPrefInt(pref, key, Integer.MIN_VALUE);
if (ret == Integer.MIN_VALUE) {
    ret = Integer.parseInt(default_value);
return ret;
intgetPrefInt(SharedPreferences pref, String key, int default_value)
get Pref Int
Object value = getPrefObject(pref, key);
int ret = default_value;
if (value != null && value instanceof String) {
    String str = (String) value;
    if (MyStringUtlis.isEmpty(str) == false) {
        try {
            ret = Integer.parseInt(str);
        } catch (Throwable e) {
...
ObjectgetPrefObject(SharedPreferences pref, String key)
get Pref Object
Map<String, ?> all = pref.getAll();
if (all != null) {
    Object obj = all.get(key);
    return obj;
return null;
ObjectgetPrefObject(SharedPreferences pref, String key)
get Pref Object
Map<String, ?> all = pref.getAll();
if (all != null) {
    Object obj = all.get(key);
    return obj;
return null;
booleangetPrefBoolean(Context c, String key, boolean defValue)
get Pref Boolean
SharedPreferences sp = PreferenceManager
        .getDefaultSharedPreferences(c);
return sp.getBoolean(key, defValue);
intgetPrefInt(Context c, String key, int defValue)
get Pref Int
SharedPreferences sp = PreferenceManager
        .getDefaultSharedPreferences(c);
return sp.getInt(key, defValue);
StringgetPrefString(Context c, String key, String defValue)
get Pref String
SharedPreferences sp = PreferenceManager
        .getDefaultSharedPreferences(c);
return sp.getString(key, defValue);
byte[]getSaltFromPreferences(SharedPreferences prefs)
get Salt From Preferences
return decode(getStringFromPrefsOrThow(prefs, KEY_PR_SALT));