Example usage for android.content SharedPreferences getBoolean

List of usage examples for android.content SharedPreferences getBoolean

Introduction

In this page you can find the example usage for android.content SharedPreferences getBoolean.

Prototype

boolean getBoolean(String key, boolean defValue);

Source Link

Document

Retrieve a boolean value from the preferences.

Usage

From source file:Main.java

public static boolean getBoolean(Context context, String key, boolean defValue) {
    SharedPreferences sp = context.getApplicationContext().getSharedPreferences(SP_NAME, Context.MODE_PRIVATE);
    return sp.getBoolean(key, defValue);
}

From source file:Main.java

public static boolean ReadSharedPreferencesBoolean(Context context, String name, String key,
        boolean defaultvalue) {
    try {/*from  w  ww .  java  2  s  .  co m*/
        SharedPreferences userInfo = context.getSharedPreferences(name, Context.MODE_WORLD_READABLE);
        return userInfo.getBoolean(key, defaultvalue);
    } catch (NullPointerException e) {
        return true;
    }
}

From source file:Main.java

public static boolean getCleanTagsBoolean(Context context) {
    SharedPreferences sharedPreferences = context.getSharedPreferences(CleanTagsBoolean, Context.MODE_PRIVATE);
    return sharedPreferences.getBoolean(CleanTagsBoolean_K, false);
}

From source file:Main.java

/**
 * Get whether speaker mode is in use when audio focus lost.
 * @param context the Context//from   www.j  a  va2s .  c o  m
 * @return true for speaker mode, false for non speaker mode
 */
public static boolean getIsSpeakerModeOnFocusLost(Context context) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);

    return prefs.getBoolean(FM_IS_SPEAKER_MODE, false);
}

From source file:Main.java

public static boolean getNotifyPrayer(Context context) {
    SharedPreferences sharedPreferences = context.getSharedPreferences(PREFERENCES_NAME, Context.MODE_PRIVATE);
    return sharedPreferences.getBoolean(NOTIFY_PRAYER, true);
}

From source file:Main.java

/**
 * Attempt to load the debugging variable from from persistent storage. Defaults to "false".
 *
 * @param context The application context
 *///www .  j a v  a2 s . c  o  m
public static void loadDebug(Context context) {
    SharedPreferences prefs = context.getSharedPreferences(PREFS, Context.MODE_PRIVATE);
    DEBUG = prefs.getBoolean("debug", false);
}

From source file:Main.java

public static boolean getPermissionBoolean(Context context) {
    SharedPreferences sharedPreferences = context.getSharedPreferences(PermissionBoolean, Context.MODE_PRIVATE);
    return sharedPreferences.getBoolean(PermissionBoolean_K, false);
}

From source file:Main.java

public static boolean getThemeIcons(Context context) {
    SharedPreferences sp = context.getSharedPreferences(ALMOSTNEXUS_PREFERENCES, Context.MODE_PRIVATE);
    boolean newD = sp.getBoolean("themeIcons", true);
    return newD;/* ww w  .  jav  a2s  .  c  o m*/
}

From source file:Main.java

public static boolean readBoolean(Context context, String fileName, String k) {
    SharedPreferences preference = context.getSharedPreferences(fileName, Context.MODE_PRIVATE);
    return preference.getBoolean(k, false);
}

From source file:Main.java

public static boolean readBoolean(Context context, String fileName, String k, boolean defBool) {
    SharedPreferences preference = context.getSharedPreferences(fileName, Context.MODE_PRIVATE);
    return preference.getBoolean(k, defBool);
}