List of usage examples for android.content SharedPreferences edit
Editor edit();
From source file:Main.java
public static boolean logout(Context context) { SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context); sharedPref.edit().putString(PREF_KEY_THEME, "").apply(); return true;/*from w ww . j av a2 s . com*/ }
From source file:Main.java
public static void bind(Context context) { SharedPreferences sp = context.getSharedPreferences("pre_tuisong", Context.MODE_PRIVATE); sp.edit().putBoolean(BIND__FLAG, true).commit(); }
From source file:Main.java
public static void unbind(Context context) { SharedPreferences sp = context.getSharedPreferences("pre_tuisong", Context.MODE_PRIVATE); sp.edit().putBoolean(BIND__FLAG, false).commit(); }
From source file:Main.java
public static void putBoolean(Context context, String key, boolean value) { try {/* w ww . ja va2s . c o m*/ SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); sp.edit().putBoolean(key, value).apply(); } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
public static void remove(Context context, String key) { try {// www.j ava 2 s . co m SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); sp.edit().remove(key).apply(); } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
public static void setInt(Context context, final String key, final int value) { final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context); settings.edit().putInt(key, value).commit(); }
From source file:Main.java
public static void setString(Context context, final String key, final String value) { final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context); settings.edit().putString(key, value).commit(); }
From source file:Main.java
public static void setPrefBoolean(Context context, final String key, final boolean value) { final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context); settings.edit().putBoolean(key, value).commit(); }
From source file:Main.java
public static void setSettingLong(Context context, final String key, final long value) { final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context); settings.edit().putLong(key, value).commit(); }
From source file:Main.java
public static void putQQid(Context context, String qqid) { SharedPreferences preferences = context.getSharedPreferences(QQ, Context.MODE_PRIVATE); preferences.edit().putString(QQ_ID, qqid).commit(); }