List of usage examples for android.content SharedPreferences edit
Editor edit();
From source file:Main.java
public static void storeStringSharePref(Context context, String key, String value) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences.Editor editor = preferences.edit(); editor.putString(key, value);// w ww .j av a 2s.co m editor.apply(); }
From source file:Main.java
public static void putBoolean(Context context, String key, boolean value) { SharedPreferences sp = context.getApplicationContext().getSharedPreferences(SP_NAME, Context.MODE_PRIVATE); Editor editor = sp.edit(); editor.putBoolean(key, value);//from w w w . j a v a 2 s. c om editor.commit(); }
From source file:Main.java
public static void clear(Context context) { SharedPreferences sp = context.getApplicationContext().getSharedPreferences(SP_NAME, Context.MODE_PRIVATE); Editor editor = sp.edit(); editor.clear();/*from w ww . j a v a2s. co m*/ editor.commit(); }
From source file:Main.java
public static void storeDistanceTravelled(Context context, int distance) { SharedPreferences sharedPref = context.getSharedPreferences("Distance", Context.MODE_PRIVATE); SharedPreferences.Editor editor = sharedPref.edit(); editor.putInt("distance", distance); editor.apply();/* w w w . jav a 2s. c o m*/ }
From source file:Main.java
public static void writeConfig(Context context, String key, String val) { SharedPreferences share = context.getSharedPreferences("perference", Context.MODE_PRIVATE); SharedPreferences.Editor editor = share.edit(); editor.putString(key, val); editor.commit();//from w ww. j a v a2 s .c o m }
From source file:Main.java
public static void setCipher(Context context, String aes) { if (null == context) { return;//from w w w.j a v a 2s . c o m } SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences.Editor editor = settings.edit(); editor.putString("cipher", aes); editor.commit(); }
From source file:Main.java
public static void saveStringSharedPreference(Context context, String key, String value) { SharedPreferences sharedPreferences = context.getSharedPreferences(SHARED_PREFERENCE_TAG, Context.MODE_PRIVATE); sharedPreferences.edit().putString(key, value).apply(); }
From source file:Main.java
public static void setCancelNotificationTime(Context context) { if (null == context) { return;/*from ww w. j a va2 s . c o m*/ } SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences.Editor editor = settings.edit(); editor.putLong("cancel_time", System.currentTimeMillis()); editor.commit(); }
From source file:Main.java
public static void save(Context context, String fileName, String key, String value) { SharedPreferences sharedPreferences = context.getSharedPreferences(fileName, context.MODE_APPEND); SharedPreferences.Editor edit = sharedPreferences.edit(); edit.putString(key, value);/*from w w w. j ava 2 s . c o m*/ }
From source file:Main.java
public static void setPreference(Context context, String preference, String value) { SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences.Editor editor = settings.edit(); editor.putString(preference, value); editor.apply();//from ww w .j a v a2 s. co m }