Example usage for android.content SharedPreferences contains

List of usage examples for android.content SharedPreferences contains

Introduction

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

Prototype

boolean contains(String key);

Source Link

Document

Checks whether the preferences contains a preference.

Usage

From source file:Main.java

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

From source file:Main.java

public static Boolean checkSharedPref(Context context, String key) {
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
    return preferences.contains(key);
}

From source file:Main.java

/**
 * Tests if the json has been cached locally
 *
 * @return True if the file has been cached
 *//*w ww  . j  ava  2s.  c o  m*/
public static boolean wasJsonCached(Activity activity) {
    SharedPreferences sharedPreferences = activity.getPreferences(Context.MODE_PRIVATE);
    return sharedPreferences.contains(SHARED_PREF_CACHED_KEY);
}

From source file:Main.java

/**
 * Returns whether the SharedPrefs storage indicates we have fired the alert before.
 *///from   w  ww . j  av a 2s . c  o m
static boolean hasAlertFiredInSharedPrefs(Context context, long eventId, long beginTime, long alarmTime) {
    SharedPreferences prefs = getFiredAlertsTable(context);
    return prefs.contains(getFiredAlertsKey(eventId, beginTime, alarmTime));
}

From source file:Main.java

public static void removePreference(Context context, final String key) {
    final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);
    if (settings.contains(key)) {
        settings.edit().remove(key).commit();
    }//from  w ww  .  ja  va2s  . co m
}

From source file:Main.java

public static boolean hasAsymmericMasterSecret(Context context) {
    SharedPreferences settings = context.getSharedPreferences(PREFERENCES_NAME, 0);
    return settings.contains(ASYMMETRIC_LOCAL_PUBLIC);
}

From source file:Main.java

public static boolean hasAsymmericMasterSecret(Context context) {
    SharedPreferences settings = context.getSharedPreferences(PREFERENCES_NAME, 0);
    return settings.contains(ASYMMETRIC_LOCAL_PUBLIC_DJB);
}

From source file:Main.java

public static boolean contains(final Context context, final String key) {
    if (context != null) {
        final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);
        return settings.contains(key);
    }// ww  w  . j  a  v  a  2 s. c  om
    return false;
}

From source file:Main.java

public static boolean hasAsymmericMasterSecret(Context context) {
    SharedPreferences settings = context.getSharedPreferences(PREFERENCES_NAME, 0);

    return settings.contains(ASYMMETRIC_LOCAL_PUBLIC_NIST) || settings.contains(ASYMMETRIC_LOCAL_PUBLIC_DJB);
}

From source file:Main.java

public static Boolean containKeySharePref(Context context, String key) {
    Boolean isContainer = false;/*  w w  w .ja v  a 2  s.co  m*/
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
    if (preferences.contains(key)) {
        isContainer = true;
    } else {
        isContainer = false;
    }
    return isContainer;

}