Example usage for android.app Activity getSharedPreferences

List of usage examples for android.app Activity getSharedPreferences

Introduction

In this page you can find the example usage for android.app Activity getSharedPreferences.

Prototype

@Override
    public SharedPreferences getSharedPreferences(String name, int mode) 

Source Link

Usage

From source file:com.breadwallet.tools.manager.SharedPreferencesManager.java

public static void putFeatureEnabled(Activity activity, boolean enabled, String feature) {
    SharedPreferences prefs = activity.getSharedPreferences(BRConstants.PREFS_NAME, Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = prefs.edit();
    editor.putBoolean(feature, enabled);
    editor.apply();// ww w.j av a 2  s.c  om
}

From source file:com.tesobe.hello_obp.lib.OBPRestClient.java

/**
 * @return true if the access token was loaded and set from shared
 *         preferences/*from w  ww . j a v a  2s  .c  o m*/
 */
public static boolean setAccessTokenFromSharedPrefs(Activity activity) {
    SharedPreferences settings = activity.getSharedPreferences(PREF_FILE, 0);
    String token = settings.getString(CONSUMER_TOKEN, PREF_NOT_SET);
    String secret = settings.getString(CONSUMER_SECRET, PREF_NOT_SET);

    boolean exists = !token.equals(PREF_NOT_SET) && !secret.equals(PREF_NOT_SET);
    // set it if it exists
    if (exists)
        consumer.setTokenWithSecret(token, secret);

    return exists;
}

From source file:com.breadwallet.tools.manager.SharedPreferencesManager.java

public static void putExchangeRates(Activity activity, Set<CurrencyEntity> rates) {
    SharedPreferences prefs = activity.getSharedPreferences(BRConstants.PREFS_NAME, Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = prefs.edit();
    editor.remove(BRConstants.EXCHANGE_RATES);
    ByteArrayOutputStream arrayOutputStream = new ByteArrayOutputStream();

    ObjectOutputStream objectOutput;
    try {/*from  w  w  w .ja va  2s . c om*/
        objectOutput = new ObjectOutputStream(arrayOutputStream);
        objectOutput.writeObject(rates);
        byte[] data = arrayOutputStream.toByteArray();
        objectOutput.close();
        arrayOutputStream.close();
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        Base64OutputStream b64 = new Base64OutputStream(out, Base64.NO_WRAP);
        b64.write(data);
        b64.close();
        out.close();
        editor.putString(BRConstants.EXCHANGE_RATES, new String(out.toByteArray()));

        editor.apply();
    } catch (IOException e) {
        e.printStackTrace();
    }

}

From source file:com.breadwallet.tools.manager.SharedPreferencesManager.java

public static void putCurrencyUnit(Activity context, int unit) {
    if (context == null)
        return;/*  w  w w.j a  va2 s. c  o  m*/
    SharedPreferences settings = context.getSharedPreferences(BRConstants.PREFS_NAME, 0);
    SharedPreferences.Editor editor = settings.edit();
    editor.putInt(BRConstants.CURRENT_UNIT, unit);
    editor.apply();
}

From source file:com.breadwallet.tools.manager.SharedPreferencesManager.java

private static void setDeviceId(Activity context, String uuid) {
    if (context == null)
        return;/*from   w  w  w .j a  va2  s .  co  m*/
    SharedPreferences settings = context.getSharedPreferences(BRConstants.PREFS_NAME, 0);
    SharedPreferences.Editor editor = settings.edit();
    editor.putString(BRConstants.USER_ID, uuid);
    editor.apply();
}

From source file:com.breadwallet.tools.manager.SharedPreferencesManager.java

public static void putLastBlockHeight(Activity context, int lastHeight) {
    if (context == null)
        return;/*from w  ww . ja  v  a 2  s.  co m*/
    SharedPreferences settings = context.getSharedPreferences(BRConstants.PREFS_NAME, 0);
    SharedPreferences.Editor editor = settings.edit();
    editor.putInt(BRConstants.LAST_BLOCK_HEIGHT, lastHeight);
    editor.apply();
}

From source file:com.breadwallet.tools.manager.SharedPreferencesManager.java

public static void putStartHeight(Activity context, int startHeight) {
    if (context == null)
        return;/*from ww  w  .  j  av a 2  s . c om*/
    SharedPreferences settings = context.getSharedPreferences(BRConstants.PREFS_NAME, 0);
    SharedPreferences.Editor editor = settings.edit();
    editor.putInt(BRConstants.START_HEIGHT, startHeight);
    editor.apply();
}

From source file:com.breadwallet.tools.manager.SharedPreferencesManager.java

public static void putTipsShown(Activity context, boolean tipsShown) {
    if (context == null)
        return;//from  w  w w  .j  a v  a  2s. c  o  m
    SharedPreferences settings = context.getSharedPreferences(BRConstants.PREFS_NAME, 0);
    SharedPreferences.Editor editor = settings.edit();
    editor.putBoolean(BRConstants.TIPS_SHOWN, tipsShown);
    editor.apply();
}

From source file:com.breadwallet.tools.manager.SharedPreferencesManager.java

public static void putBitIdNonces(Activity activity, List<Integer> nonces, String key) {
    JSONArray arr = new JSONArray();
    arr.put(nonces);//from  ww  w .  ja v  a 2s.c  om
    SharedPreferences prefs = activity.getSharedPreferences(BRConstants.PREFS_NAME, Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = prefs.edit();
    editor.putString(key, arr.toString());
    editor.apply();
}

From source file:com.dunrite.xpaper.utility.Utils.java

public static int getTheme(Activity a) {
    SharedPreferences sharedPref = a.getSharedPreferences("WALL_CONFIG", Context.MODE_PRIVATE);
    return sharedPref.getInt("theme", 0); //defaults to basic
}