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 String getPhone(Context context) { SharedPreferences preferences = context.getSharedPreferences(SETTINGS, Context.MODE_PRIVATE); return preferences.getString(PHONE, ""); }
From source file:Main.java
public static SharedPreferences appsPrefs(Context c) { return c.getSharedPreferences(PREF_FILE_APPS, Context.MODE_PRIVATE); }
From source file:Main.java
public static String getCity(Context context) { SharedPreferences sp = context.getSharedPreferences(SP_NAME, Context.MODE_PRIVATE); if (sp != null) { return sp.getString(KEY_CITY, "null"); }/*from w w w .j a v a 2s . com*/ return ""; }
From source file:Main.java
public static <T> T getObject(String preName, Context context, String key, Class<T> clazz) { SharedPreferences pre = context.getSharedPreferences(preName, Context.MODE_PRIVATE); String str = pre.getString(key, ""); return TextUtils.isEmpty(str) ? null : new Gson().fromJson(str, clazz); }
From source file:Main.java
public static boolean getBoolean(Context context, String key, boolean defValue) { SharedPreferences sp = context.getApplicationContext().getSharedPreferences(SP_NAME, Context.MODE_PRIVATE); return sp.getBoolean(key, defValue); }
From source file:Main.java
public static String getSharedPref(Context context, String key) { SharedPreferences sharedPreferences = context.getSharedPreferences(sharedPrefFileName, Context.MODE_PRIVATE); String value = sharedPreferences.getString(key, ""); return value; }
From source file:Main.java
public static void SavePreferences(Context context, String key) { SharedPreferences sharedPreferences = context.getSharedPreferences(TOKEN, Context.MODE_PRIVATE); SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putString(key, token);// www. ja va 2s .c o m editor.apply(); }
From source file:Main.java
private static void writeCache(int[] screen, Activity activity) { SharedPreferences config = activity.getSharedPreferences("config", Context.MODE_PRIVATE); Editor editor = config.edit();//from w w w . ja va 2s. c om editor.putBoolean("isAlreadyGetPhoneResolution", true); editor.putInt("height", screen[0]); editor.putInt("width", screen[1]); editor.commit(); }
From source file:Main.java
public static boolean isFirstRun(Context context) { SharedPreferences prefs = context.getSharedPreferences(PREFS, Context.MODE_PRIVATE); return prefs.getBoolean(PREF_FIRST_RUN, true); }
From source file:Main.java
public static int getMsgFirstSyncKey(String targetId, Context context) { SharedPreferences preferences = context.getSharedPreferences("messageFirstSync" + targetId, Context.MODE_PRIVATE); return preferences.getInt("targetId", 0); }