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

public static String getSharedPreferences(Context context, String fileName, String parameterName) {
    SharedPreferences sp = context.getSharedPreferences(fileName, 0);
    String parameter = sp.getString(parameterName, "");
    return parameter;
}

From source file:Main.java

public static String getPref(Context context, String name, String defaultValue) {
    SharedPreferences pref = context.getSharedPreferences("TVGuide", Context.MODE_PRIVATE);
    return pref.getString(name, defaultValue);
}

From source file:Main.java

public static String readCache(Context context, String key) {
    SharedPreferences sp = context.getSharedPreferences("cacheUtils", Context.MODE_PRIVATE);
    return sp.getString(key, "");
}

From source file:Main.java

public static String getStringValue(Context context, String key, String defValue) {
    SharedPreferences sp = context.getSharedPreferences(CONFIG_NAME, Context.MODE_PRIVATE);
    return sp.getString(key, defValue);
}

From source file:Main.java

public static String getString(Context context, String key) {
    SharedPreferences sp = context.getSharedPreferences("atguigu", Context.MODE_PRIVATE);
    return sp.getString(key, "");

}

From source file:Main.java

public static String readString(Context context, String key) {
    SharedPreferences pre = context.getSharedPreferences(STORE_NAME, Context.MODE_PRIVATE);
    return pre.getString(STORE_KEY_PREFIX + key, "");
}

From source file:Main.java

public static String getSharedPreferences(Context context, String fileName, String parameterName,
        String otherDefaultReturns) {
    SharedPreferences sp = context.getSharedPreferences(fileName, 0);
    String parameter = sp.getString(parameterName, otherDefaultReturns);
    return parameter;
}

From source file:Main.java

public static String getCacheData(Context context) {
    SharedPreferences settings = context.getSharedPreferences("Preference", 0);
    String cacheData = settings.getString("CacheData", "");
    return cacheData;
}

From source file:Main.java

public static String getPersistedData(Context context, String defaultLanguage) {
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
    return preferences.getString(SELECTED_LANGUAGE, defaultLanguage);
}

From source file:Main.java

public static boolean checkAuthorization(Context context) {
    SharedPreferences tokenInfo = context.getSharedPreferences(PREF_NAME, 0);
    String token = tokenInfo.getString("oauth_token", null);
    String tokenSecret = tokenInfo.getString("oauth_token_secret", null);
    String verifier = tokenInfo.getString("oauth_verifier", null);
    return (token != null && tokenSecret != null && verifier != null);
}