List of usage examples for android.preference PreferenceManager getDefaultSharedPreferences
public static SharedPreferences getDefaultSharedPreferences(Context context)
From source file:Main.java
public static void init(Context mContext) { if (mSharedPreferences == null) { mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext); }/*from w w w. ja va 2 s. co m*/ }
From source file:Main.java
private static final SharedPreferences getSharedPreference(Context context) { return PreferenceManager.getDefaultSharedPreferences(context); }
From source file:Main.java
public static SharedPreferences.Editor getDefaultPrefsEditor(Context ctx) { return PreferenceManager.getDefaultSharedPreferences(ctx.getApplicationContext()).edit(); }
From source file:Main.java
private static SharedPreferences getSharedPreferences(Context context) { return PreferenceManager.getDefaultSharedPreferences(context); }
From source file:Main.java
public static void setSelectedAccount(Context context, String accoutName) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); prefs.edit().putString(PREF_SELECTED_ACCOUNT, accoutName).apply(); }
From source file:Main.java
public static String GetBackupFolder(Context paramContext) { File dir = new File(Environment.getExternalStorageDirectory(), "backups"); if (!dir.exists()) dir.mkdir();/*from w w w.j ava 2 s . com*/ return PreferenceManager.getDefaultSharedPreferences(paramContext).getString("prefDBLocalFolder", dir.getAbsolutePath()); }
From source file:Main.java
public static SharedPreferences getSharedPreferences(Context context) { if (pref != null) return pref; if (context != null) { pref = PreferenceManager.getDefaultSharedPreferences(context); return pref; }/*from w w w . j av a2 s . com*/ return pref; }
From source file:Main.java
public static void addToFavorites(final Context context, long movieId) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); Set<String> set = sp.getStringSet(PREF_FAVORED_MOVIES, null); if (set == null) set = new HashSet<>(); set.add(String.valueOf(movieId)); sp.edit().putStringSet(PREF_FAVORED_MOVIES, set).apply(); }
From source file:Main.java
public static void logOutUser(Context context, String userId) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); Set<String> currentUsers = prefs.getStringSet(LOGGED_IN_USER_PREFERENCE_KEY, new HashSet<>()); currentUsers.remove(userId);//from www .j a v a 2 s. com PreferenceManager.getDefaultSharedPreferences(context).edit() .putStringSet(LOGGED_IN_USER_PREFERENCE_KEY, currentUsers).commit(); }
From source file:Main.java
public static void saveDataToSharedPref(Context context, List<String> arrayList) { SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences.Editor editor = sharedPrefs.edit(); Gson gson = new Gson(); String json = gson.toJson(arrayList); editor.putString(APP_LIST, json);//from w w w . java2s .c o m editor.commit(); }