List of usage examples for android.content SharedPreferences getBoolean
boolean getBoolean(String key, boolean defValue);
From source file:Main.java
public static boolean isNotificationFiredForBlock(Context context, String blockId) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); final String key = String.format("notification_fired_%s", blockId); boolean fired = sp.getBoolean(key, false); sp.edit().putBoolean(key, true).apply(); return fired; }
From source file:Main.java
public static boolean isNotificationFiredForBlock(Context context, String blockId) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); final String key = String.format("notification_fired_%s", blockId); boolean fired = sp.getBoolean(key, false); sp.edit().putBoolean(key, true).commit(); return fired; }
From source file:com.vel9studios.levani.popularmovies.util.AppUtils.java
public static Boolean getPreferredFavoritesState(Context context) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); return prefs.getBoolean(AppConstants.FAVORITE_PREF_KEY, false); }
From source file:Main.java
public static boolean isFeedbackNotificationFiredForSession(Context context, String sessionId) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); final String key = String.format("feedback_notification_fired_%s", sessionId); boolean fired = sp.getBoolean(key, false); sp.edit().putBoolean(key, true).commit(); return fired; }
From source file:Main.java
@TargetApi(10) private static Bitmap getSidebarWallpaperApi10(Context context, SharedPreferences preferences, int sidebarWidth, int sidebarHeight) { boolean useBackground = preferences.getBoolean("pref_sidebar_custom_background", false); if (!useBackground) return null; String path = preferences.getString("pref_sidebar_background_image", null); if (path == null) return null; try {/*from w ww. j a v a 2 s .com*/ BitmapFactory.Options bounds = decodeBounds(createWallpaperInputStream(context, path)); int decodeHeight = Math.min(bounds.outHeight, sidebarHeight); int decodeWidth = Math.min(bounds.outWidth, sidebarWidth); InputStream in = createWallpaperInputStream(context, path); try { BitmapRegionDecoder decoder = BitmapRegionDecoder.newInstance(in, false); BitmapFactory.Options options = new BitmapFactory.Options(); return decoder.decodeRegion(new Rect(0, 0, decodeWidth, decodeHeight), options); } finally { in.close(); } } catch (IOException e) { return null; } }
From source file:eu.liveGov.libraries.livegovtoolkit.helper.PermissionHelper.java
public static boolean gotPermission(Context context, String permission) { SharedPreferences shared = context.getSharedPreferences(PERMISSION_SHARED_PREFS, Context.MODE_PRIVATE); return shared.getBoolean(permission, true); }
From source file:Main.java
/** * @return {@code Boolean} value if {@code sharedPreferences} contains the value * corresponding to the {@code key}. Otherwise returns {@code null}. *//* ww w. j a va 2 s . com*/ private static Boolean getBoolean(SharedPreferences sharedPreferences, String key) { if (!sharedPreferences.contains(key)) { return null; } // Default value wouldn't be used in actual case, but it is required. return Boolean.valueOf(sharedPreferences.getBoolean(key, false)); }
From source file:com.turkcell.curio.utils.CurioUtil.java
public static boolean isFirstTimeUse(Context context) { SharedPreferences sharedPreferences = context.getSharedPreferences(Constants.SHARED_PREF_NAME_CURIO, Context.MODE_PRIVATE); return sharedPreferences.getBoolean(Constants.SHARED_PREF_KEY_FIRST_TIME_USE, true); }
From source file:com.google.ipc.invalidation.ticl.android.c2dm.C2DMSettings.java
private static boolean retrieveField(Context context, String field, boolean defaultValue) { SharedPreferences preferences = getPreferences(context); return preferences.getBoolean(field, defaultValue); }
From source file:com.fusionx.lightirc.util.SharedPreferencesUtils.java
public static boolean isInitialDatabaseRun(final Context context) { final SharedPreferences globalSettings = context.getSharedPreferences("main", MODE_PRIVATE); return globalSettings.getBoolean("firstDbRun", true); }