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 readString(Context context, String fileName, String k) {
    SharedPreferences preference = context.getSharedPreferences(fileName, Context.MODE_PRIVATE);
    return preference.getString(k, null);
}

From source file:Main.java

public static String readString(Context context, String fileName, String k, String defV) {
    SharedPreferences preference = context.getSharedPreferences(fileName, Context.MODE_PRIVATE);
    return preference.getString(k, defV);
}

From source file:Main.java

public static boolean isCorrectPasscode(Context context, String inputPasscode) {
    SharedPreferences prefs = context.getSharedPreferences(context.getPackageName(), Context.MODE_PRIVATE);

    if (prefs.getString(PREFS_KEY_PASSCODE, null).contentEquals(inputPasscode))
        return true;
    else//from   w w  w.j  av a  2  s. c om
        return false;

}

From source file:Main.java

public static String getGcmKey(final Context context, final String accountName) {
    SharedPreferences sp = getSharedPreferences(context);
    String gcmKey = sp.getString(makeAccountSpecificPrefKey(accountName, PREFIX_PREF_GCM_KEY), null);

    // if there is no current GCM key, generate a new random one
    if (TextUtils.isEmpty(gcmKey)) {
        gcmKey = UUID.randomUUID().toString();
        setGcmKey(context, accountName, gcmKey);
    }//from  w  w  w. ja v a  2  s.  c o m

    return gcmKey;
}

From source file:Main.java

/**
 * Gets the stored authToken, which may be expired
 *///from  w  ww .ja  v  a  2s . co m
public static String GetAuthToken(Context applicationContext) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(applicationContext);
    return prefs.getString("GDRIVE_AUTH_TOKEN", "");
}

From source file:Main.java

public static String getGcmId(Context context) {
    final SharedPreferences prefs = context.getSharedPreferences(PREFERENCES, Context.MODE_PRIVATE);
    return prefs.getString(PROPERTY_REG_ID, null);
}

From source file:Main.java

/**
 * Gets the stored account name//from w w w .  j a v  a 2 s. c  o m
 */
public static String GetAccountName(Context applicationContext) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(applicationContext);
    return prefs.getString("GDRIVE_ACCOUNT_NAME", "");
}

From source file:Main.java

public static String getSystemValue(String key, Context p_context) {
    String value = null;/*www  .  j a  va2 s. com*/
    SharedPreferences myPrefs = p_context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
    value = myPrefs.getString(key, null);

    return value;
}

From source file:Main.java

public static String getShareSettings(Context context) {
    SharedPreferences settings = context.getSharedPreferences(BCB_SHARED_PREF, Context.MODE_PRIVATE);
    return settings.getString(BCB_SHARED_WITH_ITEM, "Twitter");
}

From source file:Main.java

/**
 * Gets the stored account name/*from   ww w  .  j av  a2 s. co m*/
 */
public static String GetAccountName(Context applicationContext) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(applicationContext);
    return prefs.getString("GDOCS_ACCOUNT_NAME", "");

}