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 isFirstLaunch(Context context) {
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
    return preferences.getBoolean(FIRST_TIME, true);

}

From source file:Main.java

public static boolean isInitDb(Context context) {
    final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);
    return settings.getBoolean(EXTRA_ISINITDB, false);
}

From source file:Main.java

private static boolean getPreferenceBoolean(SharedPreferences sharedPref, Context context, int StrRes,
        int strResDefValue) {
    return sharedPref.getBoolean(context.getString(StrRes), Boolean.valueOf(context.getString(strResDefValue)));
}

From source file:Main.java

public static Boolean getBoolean(Context context, String key, Boolean defaultObject) {
    if (context == null)
        return defaultObject;
    SharedPreferences sp = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE);
    return sp.getBoolean(key, defaultObject);
}

From source file:Main.java

public static boolean getModeResult(Context context) {

    SharedPreferences sp = context.getSharedPreferences("config", Context.MODE_PRIVATE);

    if (sp.getBoolean("nightState", false)) {
        return true;
    } else {/* w w  w  .j a va 2 s.com*/
        return false;
    }
}

From source file:Main.java

public static boolean isFirstTimeLaunch(Context context) {
    SharedPreferences prefs = context.getSharedPreferences(LAUNCH_DETAILS, context.MODE_PRIVATE);
    return prefs.getBoolean(USER_INFO, false);
}

From source file:Main.java

/**
 * Check if app has been run once or not
 *///from   w  ww.  j ava 2  s  . c  om
public static Boolean firstTimeRun(Context context) {
    SharedPreferences appPreferences = PreferenceManager.getDefaultSharedPreferences(context);
    return appPreferences.getBoolean("prefappfirstrun", true);
}

From source file:Main.java

public static boolean getUseCelsius(Context context) {
    SharedPreferences pref = context.getSharedPreferences(SETTINGS_PREF, Context.MODE_PRIVATE);
    return pref.getBoolean(PREF_USE_CELSIUS, true);
}

From source file:Main.java

public static boolean getBooleanFromCache(Context context, String key) {
    SharedPreferences sp = context.getSharedPreferences("config", Context.MODE_PRIVATE);
    boolean isGuide = sp.getBoolean(key, false);
    return isGuide;
}

From source file:Main.java

public static boolean getMyLocationEnabled(final Context context) {
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
    return sp.getBoolean(PREF_MYLOCATION_ENABLED, false);
}