List of usage examples for android.preference PreferenceManager getDefaultSharedPreferences
public static SharedPreferences getDefaultSharedPreferences(Context context)
From source file:Main.java
/** * Removes the authToken and account name from the SharedPreferences storage * @param applicationContext/*from ww w . ja v a 2 s . c o m*/ */ public static void clearAuthToken(Context applicationContext) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(applicationContext); SharedPreferences.Editor editor = prefs.edit(); editor.remove("GDOCS_AUTH_TOKEN"); editor.remove("GDOCS_ACCOUNT_NAME"); editor.commit(); }
From source file:Main.java
public static void removeFromFavorites(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.remove(String.valueOf(movieId)); sp.edit().putStringSet(PREF_FAVORED_MOVIES, set).apply(); }
From source file:Main.java
public static boolean isCheckChangePermitted(Context context, Calendar date) { SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context); String limitActivePref = sharedPrefs.getString("active-date-key", "ALLOW_ALL"); Calendar today = Calendar.getInstance(); today.set(Calendar.HOUR_OF_DAY, 0); today.set(Calendar.MINUTE, 0); today.set(Calendar.SECOND, 0); today.set(Calendar.MILLISECOND, 0); Calendar yesterday;/* w w w . j a v a 2 s . co m*/ switch (limitActivePref) { case "ALLOW_CURRENT": return (date.compareTo(today) == 0); case "ALLOW_CURRENT_AND_NEXT_DAY": yesterday = (Calendar) today.clone(); yesterday.add(Calendar.DATE, -1); return (date.compareTo(yesterday) >= 0); case "ALLOW_CURRENT_AND_NEXT_DAY_AND_WEEKEND": yesterday = (Calendar) today.clone(); yesterday.add(Calendar.DATE, today.get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY ? -2 : -1); return (date.compareTo(yesterday) >= 0); case "ALLOW_ALL": default: return true; } }
From source file:Main.java
public static SharedPreferences getSharedPreference(Context context) { return PreferenceManager.getDefaultSharedPreferences(context); }
From source file:Main.java
private static SharedPreferences preferences(Context context) { return PreferenceManager.getDefaultSharedPreferences(context); }
From source file:Main.java
public static void setBind(Context context, boolean flag) { String flagStr = "not"; if (flag) {/*from ww w. j ava 2 s. co m*/ flagStr = "ok"; } SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); Editor editor = sp.edit(); editor.putString("bind_flag", flagStr); editor.commit(); }
From source file:Main.java
public static List<String> getLoggedInUsersAsList(Context context) { Set<String> users = PreferenceManager.getDefaultSharedPreferences(context) .getStringSet(LOGGED_IN_USER_PREFERENCE_KEY, new HashSet<>()); return new ArrayList<String>(users); }
From source file:Main.java
public static long getLastPatchLastModifiedTime(Context context) { return PreferenceManager.getDefaultSharedPreferences(context).getLong(PATCH_LAST_MODIFIED_TIME_KEY, PATCH_LAST_MODIFIED_TIME_DEFAULT); }
From source file:Main.java
public static void savePrefLong(Context context, String key, long value) { if (pref == null) { pref = PreferenceManager.getDefaultSharedPreferences(context); }/*from ww w .j a v a 2 s . c o m*/ if (editor == null) { editor = pref.edit(); } editor.putLong(key, value); editor.commit(); }
From source file:Main.java
static boolean isPronouncedSound(Context context) { Context applicationContext = context.getApplicationContext(); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(applicationContext); return preferences.getBoolean(PLAY_SOUND_ON_SLIDE, true); }