List of usage examples for android.preference PreferenceManager getDefaultSharedPreferences
public static SharedPreferences getDefaultSharedPreferences(Context context)
From source file:Main.java
public static Set<String> LoadLisPreferences(String key, Context context) { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); Set<String> value = new HashSet<String>(); value = sharedPreferences.getStringSet(key, null); return value; }
From source file:Main.java
public static void savePreferences(String key, String value, Context context) { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); Editor editor = sharedPreferences.edit(); editor.putString(key, value);//from ww w. j av a 2 s . c o m editor.commit(); }
From source file:Main.java
public static void setDefaults(String key, String value, Context context) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences.Editor editor = prefs.edit(); editor.putString(key, value);/*from w w w . jav a 2s.c o m*/ editor.commit(); }
From source file:Main.java
public static void putSharedPreferencesFloat(Context context, String key, float val) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); Editor edit = preferences.edit();//from ww w . j a v a2s . c o m edit.putFloat(key, val); edit.commit(); }
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);//from w ww . j a va2 s . c o m editor.apply(); }
From source file:Main.java
@SuppressLint("CommitPrefEdits") public static void defaultState(Context context, boolean state) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); if (!prefs.contains("wifi_state")) prefs.edit().putBoolean("wifi_state", state).commit(); }
From source file:Main.java
public static void storeBoolianSharePref(Context context, String key, Boolean value) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences.Editor editor = preferences.edit(); editor.putBoolean(key, value);/* ww w. j a va 2 s . c o m*/ editor.apply(); }
From source file:Main.java
public static void putSharedPreferencesString(Context context, String key, String val) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); Editor edit = preferences.edit();//w w w. java 2s . c o m edit.putString(key, val); edit.commit(); }
From source file:Main.java
public static void putSharedPreferencesBoolean(Context context, String key, boolean val) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); Editor edit = preferences.edit();/*from w w w .ja va 2 s . c o m*/ edit.putBoolean(key, val); edit.commit(); }
From source file:Main.java
public static String getLatestQuestionSaved(Context context) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); String questionUrl = prefs.getString(PREF_LATEST_QUESTION, null); return questionUrl; }