List of usage examples for android.content SharedPreferences getString
@Nullable String getString(String key, @Nullable String defValue);
From source file:Main.java
/** * Gets the stored authToken, which may be expired * @param applicationContext/*from ww w . ja va2 s . c o m*/ * @return the authToken, which may be expired */ public static String getAuthToken(Context applicationContext) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(applicationContext); return prefs.getString("GDOCS_AUTH_TOKEN", ""); }
From source file:Main.java
/** * getToken returns the OAuth token or "" if there isn't one. * @param context// w w w . j a v a 2 s. c o m * @return */ public static String getKalturaToken(Context context) { SharedPreferences sharedPreferences = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE); return sharedPreferences.getString(SHARED_PREFERENCES_KALTURA_TOKEN, ""); }
From source file:Main.java
/** * getToken returns the OAuth token or "" if there isn't one. * @param context/*from w w w. j a va 2 s . c o m*/ * @return */ public static String getToken(Context context) { SharedPreferences sharedPreferences = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE); return sharedPreferences.getString(SHARED_PREFERENCES_TOKEN, ""); }
From source file:Main.java
public static String getDataFromSharedPreferences(Context context, String key) { SharedPreferences settings; String value;//from w ww . j a v a 2 s. co m settings = context.getSharedPreferences(FLICKR_PREFS, Context.MODE_PRIVATE); value = settings.getString(key, null); return value; }
From source file:Main.java
/** * to retrieve a value from sharedpreference * * @param context context of calling activity * @param key key whose value is to be fetchs * @param defaultValue to be returned if key not found * @return value or defaultvalue if key not found *///from w w w . j a v a2s. co m public static String getPreference(Context context, String key, String defaultValue) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); String value = preferences.getString(key, defaultValue); logD("got key:" + key + " value:" + value); return value; }
From source file:Main.java
/** * Get the default error delegate./*from ww w .ja v a 2 s. c o m*/ * * @param context */ public static String getDefaultErrorDelegateClass(Context context) { SharedPreferences sharedPreferences = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE); return sharedPreferences.getString(SHARED_PREFERENCES_ERROR_DELEGATE_CLASS_NAME, null); }
From source file:Main.java
public static boolean checkLogin(Context context) { SharedPreferences userPreferences = context.getSharedPreferences("umeng_general_config", Context.MODE_PRIVATE); String string = userPreferences.getString("jdycode", ""); if (string.length() > 10) { return true; }// w w w . j a v a 2 s. c om return false; }
From source file:edu.cwru.apo.Auth.java
public static void loadKeys(SharedPreferences prefs) { Hex secretKey = new Hex(prefs.getString("secretKey", "0")); int counter = prefs.getInt("counter", -1); int increment = prefs.getInt("increment", 0); if (secretKey.toString().compareTo("0") == 0) return;// w ww. j a v a 2 s. co m if (counter == -1) return; if (increment == 0) return; Auth.Hmac = new DynamicHmac(secretKey, counter, increment); }
From source file:Main.java
public static String formatDate(Context context, long date) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); String format = prefs.getString("pref_date_format", "default"); if (format.equals("default")) { return DateFormat.getDateFormat(context).format(date); } else {// w ww .j a va 2s . c o m return (String) DateFormat.format(format, date); } }
From source file:Main.java
public synchronized static String getUniqueId(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();/* w w w.j a va2 s . com*/ } } return uniqueID; }