List of usage examples for android.preference PreferenceManager getDefaultSharedPreferences
public static SharedPreferences getDefaultSharedPreferences(Context context)
From source file:Main.java
public static String getPreferences(Context context, String key, String defValue) { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); String savedPref = sharedPreferences.getString(key, defValue); return savedPref; }
From source file:Main.java
public static int getDefKeyboardHeight(Context context) { if (sDefKeyboardHeight < 0) { sDefKeyboardHeight = dip2px(context, DEF_KEYBOARD_HEAGH_WITH_DP); }/* w ww . j av a2 s.co m*/ int height = PreferenceManager.getDefaultSharedPreferences(context).getInt(EXTRA_DEF_KEYBOARDHEIGHT, 0); return sDefKeyboardHeight = height > 0 && sDefKeyboardHeight != height ? height : sDefKeyboardHeight; }
From source file:Main.java
public static int getConfig(Context context, String key, int defaultValue) { return PreferenceManager.getDefaultSharedPreferences(context).getInt(key, defaultValue); }
From source file:Main.java
public static void checkStatus(Context context) { File defHosts = new File("/etc/hosts.og"); File altHosts = new File("/etc/hosts.alt"); File hosts = new File("/etc/hosts"); try {//from w w w.j a va2 s .co m if (PreferenceManager.getDefaultSharedPreferences(context).getInt("HFM_DISABLE_ADS", 0) == 1 && areFilesDifferent(hosts, altHosts)) { copyFiles(altHosts, hosts); } else if (PreferenceManager.getDefaultSharedPreferences(context).getInt("HFM_DISABLE_ADS", 0) == 0 && areFilesDifferent(hosts, defHosts) && isOurHostsFile()) { copyFiles(defHosts, hosts); } } catch (IOException e) { e.printStackTrace(); } }
From source file:Main.java
/** * Sets a shared preference key to specified int value * @param context//from ww w. ja v a2 s .com * @param key * @param value */ public static void putSharedPreferenceInt(Context context, String key, int value) { if (context != null) { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); Editor edit = sharedPreferences.edit(); edit.putInt(key, value); if (Build.VERSION.SDK_INT >= 9) { edit.apply(); } else { edit.commit(); } } }
From source file:Main.java
@SuppressLint("DefaultLocale") public static void SaveLastWallpaperDate(Context context, Calendar dateTime) { int year = dateTime.get(Calendar.YEAR); int month = dateTime.get(Calendar.MONTH); int date = dateTime.get(Calendar.DATE); String dateTimeToString = String.format("%d/%d/%d", year, month, date); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); preferences.edit().putString("wallpaper_date", dateTimeToString).commit(); }
From source file:Main.java
/** * to save in sharedpreference//from w ww. j a v a2 s . c o m * * @param context context of calling activity * @param key key for storing * @param value value to be stored */ public static void setPreference(Context context, String key, String value) { logD("saving key:" + key + " value:" + value); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences.Editor editor = preferences.edit(); editor.putString(key, value); editor.apply(); }
From source file:Main.java
private static void initializeVillage(Activity theActivity) { if (myPreferences == null) { myPreferences = PreferenceManager.getDefaultSharedPreferences(theActivity.getApplicationContext()); }/* www . j a va 2s.c o m*/ }
From source file:Main.java
public static void setPreference(Context context, String preference, int value) { SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences.Editor editor = settings.edit(); editor.putInt(preference, value);// w w w . j a v a 2 s . co m editor.apply(); }
From source file:Main.java
/** * Default Preference Helper//from ww w . jav a 2 s. com * @param context - the calling application context. * @return Shared Preferences */ private static SharedPreferences getPreferences(Context context) { return PreferenceManager.getDefaultSharedPreferences(context); }