List of usage examples for android.content Context getSharedPreferences
public abstract SharedPreferences getSharedPreferences(File file, @PreferencesMode int mode);
From source file:Main.java
public static void setCurrentUserImageProfileUri(Context context, String uri) { SharedPreferences prefs = context.getSharedPreferences(SHARED_PREFERENCES_FILE, Context.MODE_PRIVATE); prefs.edit().putString("userImageUri", uri).apply(); }
From source file:Main.java
public static String getPersonName(String personId, String personGroupId, Context context) { SharedPreferences personIdNameMap = context.getSharedPreferences(personGroupId + "PersonIdNameMap", Context.MODE_PRIVATE); return personIdNameMap.getString(personId, ""); }
From source file:Main.java
public static void remove(Context context, String key) { SharedPreferences sp = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE); SharedPreferences.Editor editor = sp.edit(); editor.remove(key).commit();// w w w . j a v a2 s . com }
From source file:Main.java
public static float getFloat(Context context, String key) { SharedPreferences sp = context.getSharedPreferences(key, Context.MODE_PRIVATE); float value;// w ww . java 2 s . com value = sp.getFloat(key, -1F); return value; }
From source file:Main.java
public static boolean contains(Context context, String key) { SharedPreferences sp = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE); return sp.contains(key); }
From source file:Main.java
public static String getString(Context context, String key) { SharedPreferences sp = context.getSharedPreferences("atguigu", Context.MODE_PRIVATE); return sp.getString(key, ""); }
From source file:Main.java
public static void saveAlarmRecord(Context context) { SharedPreferences sh = context.getSharedPreferences("alarm_record", Activity.MODE_PRIVATE); int i = sh.getInt("alarmRecord", -1); Log.i(">>>>>>>>>>>>>", i + ">>>>>>>>"); sh.edit().putInt("alarmRecord", ++i).commit(); }
From source file:Main.java
public static boolean getBoolean(Context context, String key) { SharedPreferences sp = context.getSharedPreferences(key, Context.MODE_PRIVATE); boolean value; value = sp.getBoolean(key, false);// www . j av a 2 s .c o m return value; }
From source file:Main.java
public static String readSharedPreferenceString(Context context, String key) { SharedPreferences prefs = context.getSharedPreferences("org.rowanacm.android", Context.MODE_PRIVATE); return prefs.getString(key, ""); // the default value is an empty string }
From source file:Main.java
public static long getLong(Context context, String key) { SharedPreferences sp = context.getSharedPreferences("configdata", Context.MODE_PRIVATE); return sp.getLong(key, 0); }