Java tutorial
//package com.java2s; import android.content.Context; import android.content.SharedPreferences; public class Main { public static Boolean getBoolean(Context mContext, String name, String key, Boolean defaultValue) { if (isExist(mContext, name, key)) { SharedPreferences sharedPreferences = mContext.getSharedPreferences(name, Context.MODE_PRIVATE); return sharedPreferences.getBoolean(key, defaultValue); } else { return false; } } public static boolean isExist(Context mContext, String name, String key) { SharedPreferences sharedPreferences = mContext.getSharedPreferences(name, Context.MODE_PRIVATE); return sharedPreferences.contains(key); } }