Example usage for android.content SharedPreferences getString

List of usage examples for android.content SharedPreferences getString

Introduction

In this page you can find the example usage for android.content SharedPreferences getString.

Prototype

@Nullable
String getString(String key, @Nullable String defValue);

Source Link

Document

Retrieve a String value from the preferences.

Usage

From source file:Main.java

static String loadCurrentAppKey(Context context) {
    SharedPreferences prefs = context.getSharedPreferences(AGE_PREFERENCES, Context.MODE_PRIVATE);

    return prefs.getString(AGE_CURRENT_APP_KEY, null);
}

From source file:Main.java

public static String getLatestForumPostSaved(Context context) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    String forumPostUrl = prefs.getString(PREF_LATEST_FORUM_POST, null);
    return forumPostUrl;
}

From source file:Main.java

static String getSaveLocation(Context context, String saveName) {
    SharedPreferences prefs = context.getSharedPreferences("com.ihelp101.xinsta", Context.MODE_PRIVATE);

    return prefs.getString(saveName, "Instagram").replace("file://", "").replaceAll("%20", " ");
}

From source file:Main.java

/**
 * Returns the persisted session id./*from w  w  w  . jav  a  2s  .c  om*/
 */
private static String getSessionIdFromPreference(Context context) {
    SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
    return pref.getString(PREF_SESSION_ID, null);
}

From source file:Main.java

public static String getValueOfSharedPreferences(Context context, String sharedName, String defaultValue) {
    SharedPreferences sharedPreferences = context.getSharedPreferences(SHARED_ID, Context.MODE_PRIVATE);
    return sharedPreferences.getString(sharedName, defaultValue);

}

From source file:Main.java

public static String getStringValueInSharedPreference(Context context, String key, String defaultValue) {
    SharedPreferences sharedPref = context.getSharedPreferences(SHARED_PREFERENCES, Context.MODE_PRIVATE);
    return sharedPref.getString(key, defaultValue);
}

From source file:Main.java

public static String getChosenAccountName(final Context context) {
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
    return sp.getString(PREF_CHOSEN_ACCOUNT, null);
}

From source file:Main.java

public static String readSharedPreferenceString(Context context, String key) {
    SharedPreferences prefs = context.getSharedPreferences("org.rowanacm.android", Context.MODE_PRIVATE);

    return prefs.getString(key, ""); // the default value is an empty string
}

From source file:Main.java

public static String getHomeData(Context context, String key, String default_value) {
    SharedPreferences sharedPreferences = context.getSharedPreferences(HOME_DATA, Context.MODE_PRIVATE);
    return sharedPreferences.getString(key, default_value) == null ? ""
            : sharedPreferences.getString(key, default_value);
}

From source file:Main.java

/**
 *
 * @param context//w  w w.  j a va2  s.c  om
 * @param key
 * @return
 */
public static String getString(Context context, String key) {
    SharedPreferences sharedPreferences = context.getSharedPreferences("7Yan", Context.MODE_PRIVATE);
    return sharedPreferences.getString(key, "");
}