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 getServer(@Nullable SharedPreferences argSharedPreferences) { if (argSharedPreferences == null) return baseUrl; return argSharedPreferences.getString(serverNameKey, baseUrl); }
From source file:Main.java
public static String getStringPreference(Context context, String key) { SharedPreferences sharedPreferences = context.getSharedPreferences(SHARED_PREFERENCE_TAG, Context.MODE_PRIVATE); return sharedPreferences.getString(key, ""); }
From source file:Main.java
/** * Get the latest searched location/*from w w w. ja v a2s . co m*/ * @return the list of latitude and longitude */ public static double[] getLastSearchedLocation(Context context) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); String strLatitude = prefs.getString(FM_LOCATION_LATITUDE, "0.0"); String strLongitude = prefs.getString(FM_LOCATION_LONGITUDE, "0.0"); double latitude = Double.valueOf(strLatitude); double longitude = Double.valueOf(strLongitude); return new double[] { latitude, longitude }; }
From source file:Main.java
public static Typeface getTypeface(SharedPreferences pref, String key, String defaultTypeface) { Typeface typeface = null;/*from w w w .j a va 2s .c o m*/ String fontPath = pref.getString(key, null); if (fontPath == null || fontPath.equals(defaultTypeface)) { return null; } else { try { typeface = Typeface.createFromFile(new File(fontPath)); } catch (Exception e) { } } return typeface; }
From source file:Main.java
public synchronized static String guid(Context context) { if (uniqueID == null) { SharedPreferences sharedPrefs = context.getSharedPreferences(PREF_UNIQUE_ID, Context.MODE_PRIVATE); uniqueID = sharedPrefs.getString(PREF_UNIQUE_ID, null); if (uniqueID == null) { uniqueID = UUID.randomUUID().toString(); Editor editor = sharedPrefs.edit(); editor.putString(PREF_UNIQUE_ID, uniqueID); editor.commit();//from ww w. j a v a 2s . com } } return uniqueID; }
From source file:Main.java
public static String GetNotificationRegistrationID() { SharedPreferences Prefs = PreferenceManager.getDefaultSharedPreferences(applicationContext); if (Prefs != null) return Prefs.getString(AUTH, ""); return null;/*from w w w. j a v a 2s .c om*/ }
From source file:Main.java
public static String getPlusNameImageURL(Context context) { SharedPreferences sp = getSharedPreferences(context); return hasActiveAccount(context) ? sp.getString(makeAccountSpecificPrefKey(context, PREFIX_PREF_PLUS_IMAGE_URL), null) : null;// ww w.j a va 2 s .co m }
From source file:Main.java
public static String getPlusNameImageURL(final Context context, final String accountName) { SharedPreferences sp = getSharedPreferences(context); return hasActiveAccount(context) ? sp.getString(makeAccountSpecificPrefKey(accountName, PREFIX_PREF_PLUS_IMAGE_URL), null) : null;//from www. ja va2 s. c o m }
From source file:Main.java
public static String getPersonGroupName(String personGroupId, Context context) { SharedPreferences personGroupIdNameMap = context.getSharedPreferences("PersonGroupIdNameMap", Context.MODE_PRIVATE); return personGroupIdNameMap.getString(personGroupId, ""); }
From source file:Main.java
/** * get string preferences//from w ww. j av a 2 s. com * * @param context * @param key The name of the preference to retrieve * @param defaultValue Value to return if this preference does not exist * @return The preference value if it exists, or defValue. Throws ClassCastException if there is a preference with * this name that is not a string */ public static String getString(Context context, String key, String defaultValue) { SharedPreferences settings = context.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE); return settings.getString(key, defaultValue); }