get Shared Preference Boolean - Android android.content

Android examples for android.content:SharedPreferences

Description

get Shared Preference Boolean

Demo Code

import android.content.Context;
import android.content.SharedPreferences;

public class Main{

    public static final String PREFS_NAME = "_java2s.com";
    public static boolean getSharedPreferenceBoolean(Context c,
            String preference) {//  w ww . j  a v a  2  s  .c om
        SharedPreferences settings = c.getSharedPreferences(
                PREFS_NAME, 0);
        return settings.getBoolean(preference, false);
    }
    public static boolean getSharedPreferenceBoolean(Context c,
            String preference, boolean defaultValue) {
        SharedPreferences settings = c.getSharedPreferences(
                PREFS_NAME, 0);
        return settings.getBoolean(preference, defaultValue);
    }

}

Related Tutorials