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 void setMapHintVisibility(Context context, boolean visible) { SharedPreferences sharedPref = context.getSharedPreferences(KEY_SHOW_MAP_HINT, Context.MODE_PRIVATE); sharedPref.edit().putBoolean(KEY_SHOW_MAP_HINT, visible).apply(); }
From source file:Main.java
private static void saveUsrname(Context context, String usrname) { SharedPreferences.Editor localEditor = context.getSharedPreferences(XL_PREFERENCES, Context.MODE_PRIVATE) .edit();/* ww w . ja v a 2s. co m*/ localEditor.putString("usrnmae", usrname); localEditor.commit(); }
From source file:Main.java
public static Boolean getBoolean(Context context, String key, Boolean defaultBoolean) { SharedPreferences sp = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE); return sp.getBoolean(key, defaultBoolean); }
From source file:Main.java
/** * * @param context/*from www . jav a 2s. co m*/ * @param key * @return */ public static String getString(Context context, String key) { SharedPreferences sharedPreferences = context.getSharedPreferences("7Yan", Context.MODE_PRIVATE); return sharedPreferences.getString(key, ""); }
From source file:Main.java
public static void put(Context context, String key, Object object) { SharedPreferences sp = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE); SharedPreferences.Editor editor = sp.edit(); if (object instanceof String) { editor.putString(key, (String) object); } else if (object instanceof Integer) { editor.putInt(key, (Integer) object); } else if (object instanceof Boolean) { editor.putBoolean(key, (Boolean) object); } else if (object instanceof Float) { editor.putFloat(key, (Float) object); } else if (object instanceof Long) { editor.putLong(key, (Long) object); } else {//from w w w.java2 s . com editor.putString(key, object.toString()); } editor.commit(); }
From source file:Main.java
public static void saveBoolean(Context context, String key, boolean value) { Editor editor = context.getSharedPreferences(SHARED_PREFERENCE_NAME, Context.MODE_PRIVATE).edit(); editor.putBoolean(key, value);/*from w ww .ja v a2 s . c om*/ editor.commit(); }
From source file:Main.java
public static void saveIntToSharePrefs(Context context, String fileName, String key, int value) { SharedPreferences preferences = context.getSharedPreferences(fileName, Context.MODE_PRIVATE); Editor editor = preferences.edit();/*w ww. j av a 2 s . c om*/ editor.putInt(key, value); editor.commit(); }
From source file:Main.java
public static float getFloat(Context context, String key, float defValue) { SharedPreferences sp = context.getApplicationContext().getSharedPreferences(SP_NAME, Context.MODE_PRIVATE); return sp.getFloat(key, defValue); }
From source file:Main.java
public static String getCameraId(Context context) { SharedPreferences preferences;// w w w . jav a 2s .c om String cameraid; if (context != null) { preferences = context.getSharedPreferences("CameraConfig", Context.MODE_PRIVATE); cameraid = preferences.getString("camera", "0"); } else { cameraid = "0"; } return cameraid; }
From source file:Main.java
public static boolean getReadMode(Context context, String key, boolean defValue) { SharedPreferences prefe = context.getSharedPreferences(PREFERNCE_FILE_NAME, Context.MODE_PRIVATE); return prefe.getBoolean(key, defValue); }