List of usage examples for android.preference PreferenceManager getDefaultSharedPreferences
public static SharedPreferences getDefaultSharedPreferences(Context context)
From source file:Main.java
/** * ??????????????????????/*from ww w. ja va 2s . c o m*/ */ public static long readDiffTime(Context context) { if (diff == 0) diff = PreferenceManager.getDefaultSharedPreferences(context).getLong("diff", 0); return diff; }
From source file:Main.java
private static int getIntegerPreference(Context context, String key) { int value = -1; SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); if (preferences != null) { value = preferences.getInt(key, -1); }/*from w ww .j ava2s . com*/ return value; }
From source file:Main.java
public static boolean isUserLoggedIn(Context context) { return !PreferenceManager.getDefaultSharedPreferences(context) .getStringSet(LOGGED_IN_USER_PREFERENCE_KEY, new HashSet<String>()).isEmpty(); }
From source file:Main.java
public static boolean isShowWheelchairIcon(Context context) { SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(context); return null != mPrefs && mPrefs.getBoolean("load_wheelchair_icon", true); }
From source file:Main.java
public static String getThemeName(Context context) { SharedPreferences appSettings = PreferenceManager.getDefaultSharedPreferences(context); return appSettings.getString("theme", "Dark"); }
From source file:Main.java
public static boolean getBoolean(Context context, String key, boolean defaultValue) { try {/*from w w w. j a v a 2s . c o m*/ SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); return sp.getBoolean(key, defaultValue); } catch (Exception e) { e.printStackTrace(); return defaultValue; } }
From source file:Main.java
private static float getFloatPreference(Context context, String key) { float value = -1; SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); if (preferences != null) { value = preferences.getFloat(key, Float.MIN_VALUE); }/*w ww . ja va2 s . com*/ return value; }
From source file:Main.java
private static String loadUDIDFromSP(Context context) { SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context); return pref.getString(UDID_KEY, ""); }
From source file:Main.java
public static Boolean getPreferences(Context context, String key, boolean defValue) { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); Boolean savedPref = sharedPreferences.getBoolean(key, defValue); return savedPref; }
From source file:Main.java
public static String getRole(final Context context) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); return sp.getString(PREF_ROLE, null); }