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 getPreference(Context context, String key, boolean defaultValue) {
    SharedPreferences pref = getPreferences(context);
    return pref.getBoolean(key, defaultValue);
}

From source file:Main.java

public static boolean getNotiDoNotShowFlag(Context context) {
    SharedPreferences sd = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE);
    return sd.getBoolean(DO_NOT_SHOW_FLAG, true);

}

From source file:Main.java

/**
 * Retrieves a boolean value from preference manager. If no such key exists, it will return the
 * value provided as <code>defaultValue</code>
 *//*from   w  w  w.j  ava 2  s .  com*/
public static boolean getBooleanFromPreference(Context context, String key, boolean defaultValue) {
    SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
    return pref.getBoolean(key, defaultValue);
}

From source file:Main.java

public static boolean isBind(Context context) {
    SharedPreferences sp = context.getSharedPreferences("pre_tuisong", Context.MODE_PRIVATE);
    return sp.getBoolean(BIND__FLAG, false);
}

From source file:Main.java

public static boolean isRunning(Context context) {
    SharedPreferences sp = context.getSharedPreferences(EXT_CONFIG, Context.MODE_PRIVATE);
    return sp.getBoolean(KEY_IS_RUNNING, false);
}

From source file:Main.java

private static boolean isAlreadyGetPhoneResolution(Activity activity) {
    SharedPreferences config = activity.getSharedPreferences("config", Context.MODE_PRIVATE);
    return config.getBoolean("isAlreadyGetPhoneResolution", false);
}

From source file:Main.java

private static boolean neverDisplayDialog(Context context) {
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
    return preferences.getBoolean("NEVER_SHOW_RATE_DIALOG", false);
}

From source file:Main.java

public static boolean loadAutoRefreshFromPreference(Context c) {
    SharedPreferences preferences = c.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
    return preferences.getBoolean(PREF_AUTO_REFRESH, true);
}

From source file:Main.java

public static boolean getBoolean(Context context, String key, boolean defaultValue) {
    try {/*  w w  w .  j av a  2 s  . 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

public static boolean isFirstLogin(Context context) {
    SharedPreferences preferences = getSharedPreferences(context);
    final boolean isFirstLogin = preferences.getBoolean(FIRST_LOGIN, true);
    return isFirstLogin;
}