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 HasSeenBefore(String name, Context context) {
    SharedPreferences sharedPrefs = context.getSharedPreferences(prefCategoryName, Activity.MODE_PRIVATE);
    return sharedPrefs.getBoolean(name, false);
}

From source file:Main.java

public static boolean getBooleanFromDefaults(Context context, String key) {
    if (context != null) {
        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
        return sharedPreferences.getBoolean(key, false);
    } else/*  w ww  .j a v a2 s.  c o  m*/
        return false;
}

From source file:Main.java

/**
 * Retrieve if geofencing triggers should show a notification from app preferences.
 *///  w ww  . java2 s. c  o  m
public static boolean getGeofenceEnabled(Context context) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    return prefs.getBoolean(PREFERENCES_GEOFENCE_ENABLED, true);
}

From source file:Main.java

/**
 * Return true if conference info cards are enabled, false if user has disabled them.
 *
 * @param context Context to be used to lookup the {@link android.content.SharedPreferences}.
 *///w  w w .  j av  a 2 s  . com
public static boolean isConfMessageCardsEnabled(final Context context) {
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
    return sp.getBoolean(PREF_CONF_MESSAGE_CARDS_ENABLED, false);
}

From source file:Main.java

static boolean isPronouncedSound(Context context) {
    Context applicationContext = context.getApplicationContext();
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(applicationContext);
    return preferences.getBoolean(PLAY_SOUND_ON_SLIDE, true);
}

From source file:Main.java

/**
 * Returns true if user already answered the conference info cards prompt, false if they
 * haven't yet./*from   ww w .  j  ava  2s .c om*/
 *
 * @param context Context to be used to lookup the {@link android.content.SharedPreferences}.
 */
public static boolean hasAnsweredConfMessageCardsPrompt(final Context context) {
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
    return sp.getBoolean(PREF_ANSWERED_CONF_MESSAGE_CARDS_PROMPT, false);
}

From source file:Main.java

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

From source file:Main.java

public static boolean getPosterStatus(Context context) {
    SharedPreferences sp = context.getSharedPreferences("recommend_poster", Activity.MODE_PRIVATE);
    boolean ret = sp.getBoolean("poster_status", true);
    return ret;/*w ww  .  ja va2  s . c  o  m*/
}

From source file:Main.java

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

From source file:Main.java

public static boolean getPreferenceBoolean(String preference, Context context, String key, boolean defValue) {
    SharedPreferences prefs = context.getSharedPreferences(preference, Context.MODE_PRIVATE);
    boolean value = prefs.getBoolean(key, defValue);
    return value;
}