List of usage examples for android.preference PreferenceManager getDefaultSharedPreferences
public static SharedPreferences getDefaultSharedPreferences(Context context)
From source file:Main.java
public static SharedPreferences getPrefManager(Context ctx) { return PreferenceManager.getDefaultSharedPreferences(ctx.getApplicationContext()); }
From source file:Main.java
public static void saveValueToPublicSharedPreferences(Context context, String key, String Value) { SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context); Editor editor = settings.edit();//ww w. ja v a 2 s . c o m editor.putString(key, Value); editor.commit(); }
From source file:Main.java
public static String getSettingString(final Context context, final String key, final String defaultValue) { final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context); return settings.getString(key, defaultValue); }
From source file:Main.java
public static void setPrefDisplayLineNumber(final Context context, boolean b) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); sp.edit().putBoolean(PREF_DISPLAY_LINE_NUMBER, b).commit(); }
From source file:Main.java
public static long getLastUsedTimestamp(Context context) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); return prefs.getLong(LASTUSED_PARAM, 0); }
From source file:Main.java
private static void saveWeatherInfo(Context context, String cityName, String pm25, String temp, String desc, String time) {//w ww .j av a2s.c o m SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(context).edit(); editor.putBoolean("city_selected", true); editor.putString("city_name", cityName); editor.putString("pm25", pm25); editor.putString("temp", temp); editor.putString("desc", desc); editor.putString("time", time); editor.commit(); }
From source file:Main.java
public static void isEnabled(Context context, boolean enabled) { PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean("sever_enabled", enabled).commit(); }
From source file:Main.java
public static int getFontSize(Context context) { try {/*from w ww.ja va2s .c om*/ int fontSize = Integer .parseInt(PreferenceManager.getDefaultSharedPreferences(context).getString("fontSize", "14")); if (fontSize > 2) return fontSize; } catch (NumberFormatException e) { } return DEFAULT_FONTSIZE; }
From source file:Main.java
public static void updateLastUsedTimestamp(Context context) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences.Editor edit = prefs.edit(); edit.putLong(LASTUSED_PARAM, System.currentTimeMillis()); edit.commit();// www.j ava 2 s . co m }
From source file:Main.java
public static Calendar getWallpaperDate(Context context) { Calendar wallpaperDate = Calendar.getInstance(); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); String dateTimeToString = preferences.getString("wallpaper_date", null); if (dateTimeToString == null) return wallpaperDate; wallpaperDate.set(Calendar.YEAR, Integer.parseInt(dateTimeToString.split("/")[0])); wallpaperDate.set(Calendar.MONTH, Integer.parseInt(dateTimeToString.split("/")[1])); wallpaperDate.set(Calendar.DATE, Integer.parseInt(dateTimeToString.split("/")[2])); return wallpaperDate; }