-
public class SharedPreferenceUtilCreated by shoaib on 10/13/15.
-
-
Method Summary
Modifier and Type Method Description static SharedPreferencesgetSharedPref(Context context, String fileName)static voidaddStringToSharedPreference(Context context, String spFileName, String spKey, String spValue)static voidaddIntToSharedPreference(Context context, String spFileName, String spKey, int spValue)static voidaddBooleanToSharedPreference(Context context, String spFileName, String spKey, boolean spValue)static StringgetStringFromSharedPreference(Context context, String spFileName, String spKey, String defaultValue)static intgetIntFromSharedPreference(Context context, String spFileName, String spKey, int defaultValue)static booleangetBooleanFromSharedPreference(Context context, String spFileName, String spKey, boolean defaultValue)static Map<String, out Object>getSharedPrefMap(Context context, String prefName)Simple helper method read a preference and return all the values as hashmapformat. static voidremoveAllFromSharedPref(Context context, String prefName)Simple helper method to remove all the keys from given shared pref file. -
-
Method Detail
-
getSharedPref
static SharedPreferences getSharedPref(Context context, String fileName)
-
addStringToSharedPreference
static void addStringToSharedPreference(Context context, String spFileName, String spKey, String spValue)
-
addIntToSharedPreference
static void addIntToSharedPreference(Context context, String spFileName, String spKey, int spValue)
-
addBooleanToSharedPreference
static void addBooleanToSharedPreference(Context context, String spFileName, String spKey, boolean spValue)
-
getStringFromSharedPreference
static String getStringFromSharedPreference(Context context, String spFileName, String spKey, String defaultValue)
-
getIntFromSharedPreference
static int getIntFromSharedPreference(Context context, String spFileName, String spKey, int defaultValue)
-
getBooleanFromSharedPreference
static boolean getBooleanFromSharedPreference(Context context, String spFileName, String spKey, boolean defaultValue)
-
getSharedPrefMap
static Map<String, out Object> getSharedPrefMap(Context context, String prefName)
Simple helper method read a preference and return all the values as hashmapformat.
- Parameters:
context- contextprefName- name of the perference file.
-
removeAllFromSharedPref
static void removeAllFromSharedPref(Context context, String prefName)
Simple helper method to remove all the keys from given shared pref file.
-
-
-
-