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 readFromPreferences(Context context, String preferenceName, String defaultValue) { SharedPreferences sharedPreferences = PreferenceManager .getDefaultSharedPreferences(context.getApplicationContext()); return sharedPreferences.getString(preferenceName, defaultValue); }
From source file:Main.java
@Nullable public static Uri getRingtoneUri(Context context) { Uri ringtoneUri = null;//w ww .j a va 2s . c o m Uri defaultRingtoneUri = Settings.System.DEFAULT_NOTIFICATION_URI; SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); String prefRingtoneUri = prefs.getString("pref_ringtone_uri", defaultRingtoneUri.toString()); if (prefRingtoneUri.length() > 0) ringtoneUri = Uri.parse(prefRingtoneUri); return ringtoneUri; }
From source file:Main.java
/** * Returns whether the app is authorized to perform Google API operations * * @param applicationContext// w w w. j a v a 2 s. c om * @return */ public static boolean IsLinked(Context applicationContext) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(applicationContext); String gdocsAuthToken = prefs.getString("GDOCS_AUTH_TOKEN", ""); String gdocsAccount = prefs.getString("GDOCS_ACCOUNT_NAME", ""); return gdocsAuthToken.length() > 0 && gdocsAccount.length() > 0; }
From source file:Main.java
/** * Returns whether the app is authorized to perform Google API operations * * @param applicationContext/*from w w w . j a v a 2s . com*/ * @return */ public static boolean IsLinked(Context applicationContext) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(applicationContext); String gdocsAuthToken = prefs.getString("GDRIVE_AUTH_TOKEN", ""); String gdocsAccount = prefs.getString("GDRIVE_ACCOUNT_NAME", ""); return gdocsAuthToken.length() > 0 && gdocsAccount.length() > 0; }
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 List<Integer> readSp(Context context, String key) { SharedPreferences sp = getSharedPreferences(context); List<Integer> result = new ArrayList<Integer>(); String str = sp.getString(key, ""); if (str.length() > 0) { String[] split = str.split(":"); for (String string : split) { result.add(Integer.valueOf(string)); }//ww w.j a v a 2 s . c o m } return result; }
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 String getUserToken(Context context) { SharedPreferences userPreferences = context.getSharedPreferences("umeng_general_config", Context.MODE_PRIVATE); String string = userPreferences.getString("jdycode", null); return string; }
From source file:Main.java
public static String retrieveToken() { String TOKEN_FILE = "token"; SharedPreferences preferences = context.getSharedPreferences(TOKEN_FILE, Context.MODE_PRIVATE); if (preferences != null) return preferences.getString("token", null); else/*w w w.j av a2s . c o m*/ return null; }
From source file:Main.java
public static String getMemberID(Context context) { SharedPreferences userPreferences = context.getSharedPreferences("umeng_general_config", Context.MODE_PRIVATE); String string = userPreferences.getString("ID", null); return string; }