get Boolean Share Data from SharedPreferences - Android Android OS

Android examples for Android OS:SharedPreferences

Description

get Boolean Share Data from SharedPreferences

Demo Code


//package com.java2s;

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

public class Main {
    public static final String KEY = "org.aisen.android.activityhelp_key";
    private static Context mContext;

    public static boolean getBooleanShareData(String key) {
        SharedPreferences sp = mContext.getSharedPreferences(KEY,
                Context.MODE_PRIVATE);
        return sp.getBoolean(key, false);
    }//www  .  j  ava 2s  .co  m

    public static boolean getBooleanShareData(String key, boolean defValue) {
        SharedPreferences sp = mContext.getSharedPreferences(KEY,
                Context.MODE_PRIVATE);
        return sp.getBoolean(key, defValue);
    }
}

Related Tutorials