List of usage examples for android.content Context MODE_PRIVATE
int MODE_PRIVATE
To view the source code for android.content Context MODE_PRIVATE.
Click Source Link
From source file:Main.java
public static Boolean putInt(String preName, Context context, String key, int value) { SharedPreferences pre = context.getSharedPreferences(preName, Context.MODE_PRIVATE); Editor editor = pre.edit();//www.j a va2 s . c o m editor.putInt(key, value); return editor.commit(); }
From source file:Main.java
public static long getLong(Context context, String key) { SharedPreferences shared = context.getSharedPreferences(SHARED_PREFERENCE_NAME, Context.MODE_PRIVATE); long value = shared.getLong(key, 0L); return value; }
From source file:Main.java
public static int getInt(Context context, String key, int defaultInt) { SharedPreferences sp = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE); return sp.getInt(key, defaultInt); }
From source file:Main.java
public static void putBoolean(Context context, String title, boolean content) { SharedPreferences sp = context.getSharedPreferences(FILENAME, Context.MODE_PRIVATE); SharedPreferences.Editor edit = sp.edit(); edit.putBoolean(title, content);//from ww w . j a va 2s. com edit.commit(); }
From source file:Main.java
public static boolean putLong(Context context, String key, long value) { SharedPreferences settings = context.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE); SharedPreferences.Editor editor = settings.edit(); editor.putLong(key, value);/*w w w . ja v a2s .c o m*/ return editor.commit(); }
From source file:Main.java
public static Map<String, ?> getAll(Context context) { SharedPreferences sp = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE); Map<String, ?> allKeyValue = sp.getAll(); return allKeyValue; }
From source file:Main.java
public static void removeString(Context mContext, String name, String key) { SharedPreferences sharedPreferences = mContext.getSharedPreferences(name, Context.MODE_PRIVATE); Editor editor = sharedPreferences.edit(); editor.remove(key);/* ww w.ja va2 s .c o m*/ editor.commit(); }
From source file:Main.java
public static void removePreferenceNoId(Context ctx, String param) { SharedPreferences settings = ctx.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE); SharedPreferences.Editor editor = settings.edit(); editor.remove(param);/* ww w. ja v a 2 s.com*/ editor.commit(); }
From source file:Main.java
public static String getPreference(Context context, String key) { SharedPreferences prefs = context.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE); String value = prefs.getString(key, ""); return value; }
From source file:Main.java
public static Boolean putFloat(String preName, Context context, String key, float value) { SharedPreferences pre = context.getSharedPreferences(preName, Context.MODE_PRIVATE); Editor editor = pre.edit();/* ww w. j a v a 2 s. c o m*/ editor.putFloat(key, value); return editor.commit(); }