Check if SharedPreferences has a key - Android Android OS

Android examples for Android OS:SharedPreferences

Description

Check if SharedPreferences has a key

Demo Code


//package com.java2s;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

public class Main {
    private static final String REDU_PIN_CODE = "REDU_PIN_CODE";

    public static boolean has(Context context) {
        return getPrefs(context).contains(REDU_PIN_CODE);
    }/*www .  j a  v a  2s. co  m*/

    private static SharedPreferences getPrefs(Context context) {
        return PreferenceManager.getDefaultSharedPreferences(context);
    }
}

Related Tutorials