List of usage examples for android.content SharedPreferences getBoolean
boolean getBoolean(String key, boolean defValue);
From source file:Main.java
static boolean getUserAdPref(Context context) { SharedPreferences sharedPreferences = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE); return sharedPreferences.getBoolean(USER_AD_PREF_NAME, false); }
From source file:Main.java
/** * Check to see if the user has seen the network error message so we don't need to display it repeatedly * @param context// w w w .j a v a 2s . com * @return True if the user has seen the network error message, false otherwise */ public static boolean hasSeenNetworkErrorMessage(Context context) { SharedPreferences sharedPreferences = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE); return sharedPreferences.getBoolean(SHARED_PREFERENCES_DISMISSED_NETWORK_ERROR, false); }
From source file:Main.java
public static boolean isReviewDone(Context context) { SharedPreferences sharedPreferences = context.getSharedPreferences(REVIEW_PREFS, Context.MODE_PRIVATE); return sharedPreferences.getBoolean(KEY_REVIEW_DONE, false); }
From source file:Main.java
/** * Retrieve a boolean value from the preferences. * * @param context to retrieve Default SharedPreferences. * @param key The name of the preference to modify. * @param value The new value for the preference. * * @return Returns the preference value if it exists, or defValue. Throws * ClassCastException if there is a preference with this name that is not * a boolean.// w w w . j a v a 2s. c o m * * @throws ClassCastException * * @see {@link android.preference.PreferenceManager#getDefaultSharedPreferences(Context)}. */ public static boolean loadPrefs(Context context, String key, boolean value) { SharedPreferences getPrefs = PreferenceManager.getDefaultSharedPreferences(context); return getPrefs.getBoolean(key, value); }
From source file:Main.java
public static boolean getCreateIcon(Context context) { try {/*from w w w .ja v a 2 s .co m*/ SharedPreferences sharedPreferences = context.getSharedPreferences("com.cmmobi.icuiniao.firstrun", Activity.MODE_PRIVATE); return sharedPreferences.getBoolean("create", false); } catch (Exception e) { } return false; }
From source file:Main.java
public static Boolean fetchBoolianSharePref(Context context, String key) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences.Editor prefsEditor = preferences.edit(); return preferences.getBoolean(key, false); }
From source file:com.example.android.touroflondon.Util.java
/** * Returns true if route data has been loaded into the database. * * @param context//w w w .ja v a 2 s .c o m * @return */ public static boolean hasDataLoaded(Context context) { SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context); return pref.getBoolean(PREFERENCE_DATA_LOADED, false); }
From source file:Main.java
public static String formatTime(Context context, long time) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); boolean hour24 = prefs.getBoolean("pref_24_hour_format", true); boolean showSeconds = prefs.getBoolean("pref_show_seconds", false); String hour = "kk"; String min = "mm"; String sec = ":ss"; String post = ""; if (hour24) { hour = "kk"; } else {/*from www .j a v a2s .c o m*/ hour = "hh"; post = "aa"; } if (showSeconds) { sec = ":ss"; } else { sec = ""; } String format = String.format("%s:%s%s%s", hour, min, sec, post); return (String) DateFormat.format(format, time); }
From source file:Main.java
/** * Gets a boolean value from preferences * * @param context the context//from www . j a v a 2 s . c om * @param keyId the key id * @param defaultValue the default value * @return the stored boolean value */ public static boolean getBoolean(Context context, @StringRes int keyId, boolean defaultValue) { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); return sharedPreferences.getBoolean(getKey(context, keyId), defaultValue); }
From source file:Main.java
public static boolean isControllerEnabled(Context context) { SharedPreferences prefs = context.getSharedPreferences(context.getPackageName(), Context.MODE_PRIVATE); // By default, when first time used, status is enabled return prefs.getBoolean(PREFS_CONTROLLER_STATUS, true); }