List of usage examples for android.content SharedPreferences getBoolean
boolean getBoolean(String key, boolean defValue);
From source file:Main.java
public static boolean getPreferenceBoolean(Context context, String key, boolean defValue) { SharedPreferences prefs = context.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE); boolean value = prefs.getBoolean(key, defValue); return value; }
From source file:Main.java
public static Boolean getBoolean(Context mContext, String name, String key, Boolean defaultValue) { if (isExist(mContext, name, key)) { SharedPreferences sharedPreferences = mContext.getSharedPreferences(name, Context.MODE_PRIVATE); return sharedPreferences.getBoolean(key, defaultValue); } else {/* w w w . ja va2s.c o m*/ return false; } }
From source file:Main.java
public static boolean getBoolean(Context context, String key, boolean defaultValue) { SharedPreferences sharedPreferences = context.getSharedPreferences(PRE_NAME, Context.MODE_PRIVATE); boolean userGuide = sharedPreferences.getBoolean(key, defaultValue); return userGuide; }
From source file:Main.java
public static Boolean getRatingNoti(Context context) { Boolean result = true;//from w ww. j a v a 2s.c om try { SharedPreferences settings = context.getSharedPreferences("Settings", Context.MODE_PRIVATE); result = settings.getBoolean("rating_noti", true); } catch (Exception e) { e.printStackTrace(); } return result; }
From source file:Main.java
public static Boolean isNightMode(Context context) { Boolean result = false;//from w w w . ja va 2 s .co m try { SharedPreferences settings = context.getSharedPreferences("Settings", Context.MODE_PRIVATE); result = settings.getBoolean("night_mode", false); } catch (Exception e) { e.printStackTrace(); } return result; }
From source file:Main.java
public static void changeRingtone(Context context) { SharedPreferences preferences = context.getSharedPreferences("randomizer", Context.MODE_PRIVATE); if (!preferences.getBoolean("active", false)) return;// w ww . j av a 2s. c o m RingtoneManager mgr = new RingtoneManager(context); Random random = new Random(System.currentTimeMillis()); int n = random.nextInt(mgr.getCursor().getCount()); RingtoneManager.setActualDefaultRingtoneUri(context, RingtoneManager.TYPE_RINGTONE, mgr.getRingtoneUri(n)); }
From source file:Main.java
public static boolean getBoolean(Context context, String key) { SharedPreferences sharedPreferences = context.getSharedPreferences("Zelory", Context.MODE_PRIVATE); return sharedPreferences.getBoolean(key, false); }
From source file:Main.java
public static boolean isLight(Context context) { SharedPreferences preferences = context.getSharedPreferences(APP_THEME_LIGHT, Context.MODE_PRIVATE); boolean isLight = preferences.getBoolean(APP_LIGHT_KEY, true); return isLight; }
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
/** * get boolean preferences//from ww w . j a va2 s.co m * * @param context * @param key The name of the preference to retrieve * @param defaultValue Value to return if this preference does not exist * @return The preference value if it exists, or defValue. Throws ClassCastException if there is a preference with * this name that is not a boolean */ public static boolean getBoolean(Context context, String key, boolean defaultValue) { SharedPreferences settings = context.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE); return settings.getBoolean(key, defaultValue); }