Example usage for android.content Context getSharedPreferences

List of usage examples for android.content Context getSharedPreferences

Introduction

In this page you can find the example usage for android.content Context getSharedPreferences.

Prototype

public abstract SharedPreferences getSharedPreferences(File file, @PreferencesMode int mode);

Source Link

Document

Retrieve and hold the contents of the preferences file, returning a SharedPreferences through which you can retrieve and modify its values.

Usage

From source file:Main.java

public static void setWebviewHelpStatus(Context context, boolean status) {
    SharedPreferences sp = context.getSharedPreferences("webview_help", Activity.MODE_PRIVATE);
    SharedPreferences.Editor tor = sp.edit();
    tor.putBoolean("webview_help", status);
    tor.commit();// ww  w . j  a  v  a  2s .c  om
}

From source file:Main.java

public static void setDesktopBlocked(Context context, boolean block) {
    SharedPreferences sp = context.getSharedPreferences(ALMOSTNEXUS_PREFERENCES, Context.MODE_PRIVATE);
    ;/*from  w w  w  . j  a  v a 2 s .  co  m*/
    SharedPreferences.Editor editor = sp.edit();
    editor.putBoolean("desktopBlocked", block);
    editor.commit();
}

From source file:Main.java

public static void setPosterStatus(Context context, boolean status) {
    SharedPreferences sp = context.getSharedPreferences("recommend_poster", Activity.MODE_PRIVATE);
    SharedPreferences.Editor tor = sp.edit();
    tor.putBoolean("poster_status", status);
    tor.commit();//ww w  .  j  a  v a2 s . com
}

From source file:Main.java

public static void setFloat(Context ctx, String key, Float value) {
    SharedPreferences sp = ctx.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
    sp.edit().clear();/*  ww  w  .ja va2s  . co  m*/
    sp.edit().putFloat(key, value).commit();
}

From source file:Main.java

public static String getFromSp(Context ctx, String spName, String key) {
    SharedPreferences sp = ctx.getSharedPreferences(spName, Context.MODE_PRIVATE);
    return sp.getString(key, null);
}

From source file:Main.java

public static void clearWLPref(Context paramContext) {
    SharedPreferences.Editor localEditor = paramContext.getSharedPreferences("WLPrefs", 0).edit();
    localEditor.clear();//w ww  .  j a va 2s  .c o m
    localEditor.commit();
}

From source file:Main.java

public static void SpIntertBoolean(Context c, String key, Boolean value) {
    SharedPreferences sp = c.getSharedPreferences("XGram", Context.MODE_WORLD_READABLE);
    SharedPreferences.Editor editor = sp.edit();
    editor.putBoolean(key, value);/* w  w  w.j  a  v a  2s.co  m*/
    editor.apply();
}

From source file:Main.java

public static String getShareSettings(Context context) {
    SharedPreferences settings = context.getSharedPreferences(BCB_SHARED_PREF, Context.MODE_PRIVATE);
    return settings.getString(BCB_SHARED_WITH_ITEM, "Twitter");
}

From source file:Main.java

public static boolean getUpdatesNotificationEnabled(Context context) {
    SharedPreferences settings = context.getSharedPreferences(BCB_UPDATES_SHARED_PREF, Context.MODE_PRIVATE);
    return settings.getBoolean(BCB_UPDATE_NOTIFICATION_STATE, false);
}

From source file:Main.java

public static void setFirstRunComplete(boolean value, Context context) {
    SharedPreferences.Editor prefsEditor = context.getSharedPreferences(PREFS, MODE).edit();
    prefsEditor.putBoolean(PREF_FIRST_RUN, false);
    prefsEditor.commit();/*from   www.j a  va  2  s.c o  m*/
}