Android SharedPreferences Get getPrefBoolean(SharedPreferences pref, String key)

Here you can find the source of getPrefBoolean(SharedPreferences pref, String key)

Description

get Pref Boolean

Declaration

public static Boolean getPrefBoolean(SharedPreferences pref, String key) 

Method Source Code

//package com.java2s;

import android.content.SharedPreferences;

import java.util.Map;

public class Main {
    public static Boolean getPrefBoolean(SharedPreferences pref, String key) {
        Object value = getPrefObject(pref, key);
        return value != null ? (Boolean) value : null;
    }/*from  w  w w .  j av  a  2s .co  m*/

    protected static Object getPrefObject(SharedPreferences pref, String key) {

        Map<String, ?> all = pref.getAll();
        if (all != null) {
            Object obj = all.get(key);
            return obj;
        }

        return null;
    }
}

Related

  1. getPrefBoolean(SharedPreferences pref, String key)
  2. getPrefInt(SharedPreferences pref, String key, String default_value)
  3. getPrefInt(SharedPreferences pref, String key, int default_value)
  4. getPrefObject(SharedPreferences pref, String key)
  5. getPrefObject(SharedPreferences pref, String key)