Android Context Get getBoolean(Context context, String key, boolean defValue)

Here you can find the source of getBoolean(Context context, String key, boolean defValue)

Description

get Boolean

Declaration

public static synchronized boolean getBoolean(Context context,
            String key, boolean defValue) 

Method Source Code

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

public class Main {
    private static SharedPreferences sSharedPreferences;

    public static synchronized boolean getBoolean(Context context,
            String key, boolean defValue) {
        return getDefaultSharedPreferences(context).getBoolean(key,
                defValue);//from w  ww . j  a  va  2  s. c o  m
    }

    /**
     * Does file IO on calling thread. Can use {@link #getDefaultSharedPrefsAsync(android.content.Context, couk.doridori.android.lib.prefs.AbsPrefsHelper.PrefsLoader)} if on UI
     *
     * @param context
     * @return
     */
    public static synchronized SharedPreferences getDefaultSharedPreferences(
            Context context) {
        if (sSharedPreferences == null)
            sSharedPreferences = context.getSharedPreferences(
                    "defaultPrefs", Context.MODE_PRIVATE);

        return sSharedPreferences;
    }
}

Related

  1. getApplicationName(Context ctx)
  2. getAsset(@Nonnull Context context, @Nonnull String path)
  3. getAsset(@Nonnull Context context, @Nonnull String path)
  4. getAuthorityFromPermission(Context context, String permission)
  5. getBatteryUsageInfo(Context context)
  6. getBroadcastAddress(Context context)
  7. getCarrier(Context context)
  8. getCertificateFingerprint(Context ctx, String packageName)
  9. getCertificateFromSDCard(Context context)