List of usage examples for android.content SharedPreferences getString
@Nullable String getString(String key, @Nullable String defValue);
From source file:Main.java
public static String getDefaults(String key, Context context) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); return preferences.getString(key, "false"); }
From source file:Main.java
public static String getThemeName(Context context) { SharedPreferences appSettings = PreferenceManager.getDefaultSharedPreferences(context); return appSettings.getString("theme", "Dark"); }
From source file:Main.java
public static String getPreference(Context context, String key, String defaultValue) { SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context); return settings.getString(key, defaultValue); }
From source file:Main.java
public static synchronized String getUserName(final Context context) { SharedPreferences pref = context.getSharedPreferences(KEY_STORAGE, Context.MODE_PRIVATE); return pref.getString(AUTH_NAME, null); }
From source file:Main.java
public static boolean isLogin(Context context) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); String account = sp.getString("account", null); return account != null; }
From source file:Main.java
/** * Get value by key in config// w ww . ja va 2 s.c o m * @param context context * @param key the key * @param defaultValue if can't find the value of key, will return default value * @return value */ public static String getString(Context context, String key, String defaultValue) { SharedPreferences sp = context.getSharedPreferences(NAME, Context.MODE_PRIVATE); return sp.getString(key, defaultValue); }
From source file:Main.java
public static String getString(Context context, String key, String defaultValue) { try {//w w w . j a va 2s.c om SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); return sp.getString(key, defaultValue); } catch (Exception e) { e.printStackTrace(); return defaultValue; } }
From source file:Main.java
public static String readSharedSetting(Context ctx, String settingName, String defaultValue) { SharedPreferences sharedPref = ctx.getSharedPreferences("OnBoardFile", Context.MODE_PRIVATE); return sharedPref.getString(settingName, defaultValue); }
From source file:Main.java
public static String getStringProperty(Context context, String key, String fileName) { SharedPreferences sp = context.getSharedPreferences(fileName, Context.MODE_PRIVATE); return sp.getString(key, null); }
From source file:Main.java
public static String getString(Context mContext, String key) { String result = ""; SharedPreferences sp = mContext.getSharedPreferences(SP_NAME, Context.MODE_PRIVATE); result = sp.getString(key, ""); return result; }