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

private static String getString(String key, Context context) {
    //        SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);
    SharedPreferences settings = createSharedPreferences(context);
    return settings.getString(key, null);
}

From source file:Main.java

public static String getStringFromSP(Context con, String key) {
    SharedPreferences pref = con.getSharedPreferences(PREFERENCE_NAME, 0);
    return pref.getString(key, " ");
}

From source file:Main.java

public static String getStringSharedPreferences(Context context, String name, String key, String defaultValue) {
    SharedPreferences preferences = context.getSharedPreferences(name, 0);
    return preferences.getString(key, defaultValue == null ? "" : defaultValue);
}

From source file:Main.java

public static String getUserInfo(Context context, String key, String defValue) {
    SharedPreferences sp = context.getSharedPreferences("saveSelfInfo", 0);
    return sp.getString(key, defValue);
}

From source file:Main.java

public static String getHelpDeskEmail(Context context) {
    SharedPreferences prefs = getPreference(context);
    String result = prefs.getString(SHARED_PREFERENCE_NAME_HELPDESK_EMAIL, "");

    return result;
}

From source file:Main.java

public static String getMail(Context c) {
    SharedPreferences preferences = c.getSharedPreferences(PREFS_NAME, 0);

    return preferences.getString("mail", "");
}

From source file:Main.java

public static String getString(Context ctx, String key, String defaultValue) {
    SharedPreferences sp = ctx.getSharedPreferences(PREF_NAME, ctx.MODE_PRIVATE);
    return sp.getString(key, defaultValue);
}

From source file:Main.java

public static String getStringFromDefault(Context context, String key, String defValue) {
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
    return sp.getString(key, defValue);
}

From source file:Main.java

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

From source file:Main.java

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