List of usage examples for android.content SharedPreferences edit
Editor edit();
From source file:Main.java
public static void putSharedPreferencesInt(Context context, String key, int value) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences.Editor edit = preferences.edit(); edit.putInt(key, value);/*from w w w. j ava 2 s . c o m*/ edit.apply(); }
From source file:Main.java
public static void setMuteState(Context context, boolean is_Mute) { if (context != null) { SharedPreferences settings = context.getSharedPreferences(PREFS_NAME, 0); SharedPreferences.Editor editor = settings.edit(); editor.putBoolean(MUTE_STATE, is_Mute); editor.commit();/*from w w w . j av a 2 s . com*/ } }
From source file:Main.java
public static void putSharedPreferencesBoolean(Context context, String key, boolean val) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences.Editor edit = preferences.edit(); edit.putBoolean(key, val); edit.apply();/*from www . j a v a 2 s.c o m*/ }
From source file:Main.java
public static void setArea(String area, Context ctx) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(ctx); SharedPreferences.Editor editor = preferences.edit(); editor.putString("selectedArea", area); editor.commit();/* w ww .java2 s . co m*/ }
From source file:Main.java
public static void setBooleanValue(Context context, String key, boolean value) { SharedPreferences sp = context.getSharedPreferences(CONFIG_NAME, Context.MODE_PRIVATE); SharedPreferences.Editor editor = sp.edit(); editor.putBoolean(key, value).commit(); }
From source file:Main.java
public static void setStoredVar(Activity activity, String key, String val) { SharedPreferences settings = activity.getSharedPreferences(key, Context.MODE_PRIVATE); SharedPreferences.Editor editor = settings.edit(); editor.putString(key, val); editor.commit();/* w w w . j av a 2s. c o m*/ }
From source file:Main.java
public static void removePreference(Context context, String preference) { SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences.Editor editor = settings.edit(); editor.remove(preference);/* w w w . j ava 2 s .c o m*/ editor.apply(); }
From source file:Main.java
public static void removeString(Context context, String key) { SharedPreferences shared = context.getSharedPreferences(SHARED_PREFERENCE_NAME, Context.MODE_PRIVATE); Editor editor = shared.edit(); editor.remove(key);//from w w w .j a v a 2 s . com editor.commit(); }
From source file:Main.java
public static void setReferenceString(String key, String value, Context context) { SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences.Editor editor = settings.edit(); editor.putString(key, value);//from w w w . ja v a 2s . c o m editor.commit(); }
From source file:Main.java
public static void setStringValue(Context context, String key, String value) { SharedPreferences sp = context.getSharedPreferences(CONFIG_NAME, Context.MODE_PRIVATE); SharedPreferences.Editor editor = sp.edit(); editor.putString(key, value).commit(); }