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 getUserKey(Context context) { SharedPreferences settings = context.getSharedPreferences(BCB_UPDATES_SHARED_PREF, Context.MODE_PRIVATE); return settings.getString(BCB_USER_KEY, null); }
From source file:Main.java
public static int getTrainingWordsSetting(Context context) { Context applicationContext = context.getApplicationContext(); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(applicationContext); String count = preferences.getString(TRAINING_WORDS_COUNT, Integer.toString(TRAINING_VIEW_PAGER_COUNT)); try {/*from www . j ava2s .c o m*/ return Integer.parseInt(count); } catch (NumberFormatException ex) { return TRAINING_VIEW_PAGER_COUNT; } }
From source file:Main.java
public static String getFacebookId(Context context) { if (facebookId != null) return facebookId; else {/*from w ww.j a v a 2 s . c om*/ SharedPreferences prefs = context.getSharedPreferences("profilo", Context.MODE_PRIVATE); String id = prefs.getString("reg_id", ""); if (id.isEmpty()) { Log.e("HELPER_FACEBOOK", "id facebook not found."); return null; } else { facebookId = id; return facebookId; } } }
From source file:Main.java
public static String getAccountId(final Context context) { SharedPreferences sp = getSharedPreferences(context); return hasActiveAccount(context) ? sp.getString(makeAccountSpecificPrefKey(context, PREFIX_PREF_ID), null) : null;//w w w . j a v a 2 s . co m }
From source file:Main.java
public static String getChatBg(Context context, String key) { SharedPreferences spf = context.getSharedPreferences("chat", Context.MODE_PRIVATE); if (spf.contains(key)) { return spf.getString(key, ""); }/*w w w .jav a 2s . c o m*/ return ""; }
From source file:Main.java
public static void removeContentFromSharedPreferences(SharedPreferences sharedPreferences, String key) { Editor editor = sharedPreferences.edit(); String msg = sharedPreferences.getString(key, null); editor.remove(key);/* w ww . j a v a2s.c o m*/ editor.commit(); }
From source file:Main.java
/** * Returns when the last save has been done: AM or PM * @param context// ww w . jav a 2 s . com * @return */ public static String getLastSave(Context context) { SharedPreferences prefs = context.getSharedPreferences(SHARED_PREFS_FILE, Context.MODE_PRIVATE); return prefs.getString(KEY_LAST_SAVE, "PM"); }
From source file:Main.java
/** * Gets the preference.// w ww . j a v a 2s . com * * @param key the key * @param defaultValue the default value * @return the preference */ public static String getPreference(String key, String defaultValue, Context c) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(c); return preferences.getString(key, defaultValue); }
From source file:Main.java
/** * Method to get the current user image path to retrieve ans display it * * @param context the application context * @return the saved image path//from w w w. ja v a 2 s . c o m */ public static String getCurrentUserImagePath(Context context) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); return preferences.getString(USER_IMAGE_PATH, USER_DEFAULT_IMAGE_PATH); }
From source file:Main.java
public static String getFacebookUserName(Context context) { if (facebookUserName != null) return facebookUserName; else {//from w ww . java 2s .c o m SharedPreferences prefs = context.getSharedPreferences("profilo", Context.MODE_PRIVATE); String name = prefs.getString("reg_username", ""); if (name.isEmpty()) { Log.e("HELPER_FACEBOOK", "username facebook not found."); return null; } else { facebookUserName = name; return facebookUserName; } } }