List of usage examples for android.preference PreferenceManager getDefaultSharedPreferences
public static SharedPreferences getDefaultSharedPreferences(Context context)
From source file:Main.java
public static void setLoggedIn(final Context context, boolean isLoggedIn) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); sp.edit().putBoolean(PREF_LOGGED_IN, isLoggedIn).commit(); }
From source file:Main.java
public static boolean isAnalyticsEnabled(final Context context) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); return sp.getBoolean(PREF_ANALYTICS_ENABLED, true); }
From source file:Main.java
public static boolean hasEnabledBle(Context context) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); return sp.getBoolean(PREF_BLE_ENABLED, false); }
From source file:Main.java
public static void markDeclinedWifiSetup(final Context context) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); sp.edit().putBoolean(PREF_DECLINED_WIFI_SETUP, true).commit(); }
From source file:Main.java
/** * check it is the first time to use Fm// w w w. j a v a 2s. co m */ public static boolean isFirstTimePlayFm(Context context) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); boolean isFirstTime = prefs.getBoolean(FM_IS_FIRST_TIME_PLAY, true); return isFirstTime; }
From source file:Main.java
public static void setCurSyncInterval(final Context context, long interval) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); sp.edit().putLong(PREF_CUR_SYNC_INTERVAL, interval).commit(); }
From source file:Main.java
public static int getIntPreference(Context context, String key, int def) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); return sp.getInt(key, def); }
From source file:Main.java
public static boolean isBeamUnlocked(Context context) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); return (prefs.getInt(PREF_BEAM_STATE, BEAM_STATE_LOCKED) == BEAM_STATE_UNLOCKED); }
From source file:Main.java
public static void putIntPreference(Context context, String key, int value) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); sp.edit().putInt(key, value).apply(); }
From source file:Main.java
/** * to retrieve a value from sharedpreference * * @param context context of calling activity * @param key key whose value is to be fetchs * @param defaultValue to be returned if key not found * @return value or defaultvalue if key not found *//* ww w . ja v a2 s .co m*/ public static String getPreference(Context context, String key, String defaultValue) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); String value = preferences.getString(key, defaultValue); logD("got key:" + key + " value:" + value); return value; }