List of usage examples for android.content Context MODE_PRIVATE
int MODE_PRIVATE
To view the source code for android.content Context MODE_PRIVATE.
Click Source Link
From source file:Main.java
public static Object get(Context context, String key, Object defaultObject) { SharedPreferences sp = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE); if (defaultObject instanceof String) { return sp.getString(key, (String) defaultObject); } else if (defaultObject instanceof Integer) { return sp.getInt(key, (Integer) defaultObject); } else if (defaultObject instanceof Boolean) { return sp.getBoolean(key, (Boolean) defaultObject); } else if (defaultObject instanceof Float) { return sp.getFloat(key, (Float) defaultObject); } else if (defaultObject instanceof Long) { return sp.getLong(key, (Long) defaultObject); }//from www . j a va 2s . c o m return null; }
From source file:Main.java
public static void createPreferences(Context context) { SharedPreferences pref = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE); Editor editor = pref.edit();//from w ww . j a va 2 s . c o m editor.commit(); System.out.println("Preferences created"); }
From source file:Main.java
public static void saveStringToSharePrefs(Context context, String fileName, String key, String value) { SharedPreferences preferences = context.getSharedPreferences(fileName, Context.MODE_PRIVATE); Editor editor = preferences.edit();//www . j a v a 2s. c om editor.putString(key, value); editor.commit(); }
From source file:Main.java
public static String getPersonGroupName(String personGroupId, Context context) { SharedPreferences personGroupIdNameMap = context.getSharedPreferences("PersonGroupIdNameMap", Context.MODE_PRIVATE); return personGroupIdNameMap.getString(personGroupId, ""); }
From source file:Main.java
public static void saveLoginUserName(Context context, String loginUserName) { SharedPreferences.Editor localEditor = context.getSharedPreferences(XL_PREFERENCES, Context.MODE_PRIVATE) .edit();//w ww . ja va 2 s .c o m localEditor.putString("loginUserName", loginUserName); localEditor.commit(); }
From source file:Main.java
public static void removeSharedPref(Context context, String key) { SharedPreferences sharedPreferences = context.getSharedPreferences(sharedPrefFileName, Context.MODE_PRIVATE); SharedPreferences.Editor editor = sharedPreferences.edit(); editor.remove(key);/*from w w w . j ava 2s . c om*/ editor.commit(); }
From source file:Main.java
public static int getSharedPreInteger(Context context, String key) { settings = context.getSharedPreferences(XML_Settings, Context.MODE_PRIVATE); return settings.getInt(key, 0); }
From source file:Main.java
public static void saveLoginUserPasswd(Context context, String loginUserPasswd) { SharedPreferences.Editor localEditor = context.getSharedPreferences(XL_PREFERENCES, Context.MODE_PRIVATE) .edit();/*from w w w . ja v a 2 s. c om*/ localEditor.putString("loginUserPasswd", loginUserPasswd); localEditor.commit(); }
From source file:Main.java
public static boolean getThemeIcons(Context context) { SharedPreferences sp = context.getSharedPreferences(ALMOSTNEXUS_PREFERENCES, Context.MODE_PRIVATE); boolean newD = sp.getBoolean("themeIcons", true); return newD;/*from w ww . j ava 2 s . co m*/ }
From source file:Main.java
public static boolean contains(Context context, String key) { SharedPreferences sp = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE); return sp.contains(key); }