List of usage examples for android.app Activity getSharedPreferences
@Override public SharedPreferences getSharedPreferences(String name, int mode)
From source file:com.breadwallet.tools.manager.SharedPreferencesManager.java
@SuppressWarnings("unchecked") public static Set<CurrencyEntity> getExchangeRates(Activity context) { SharedPreferences prefs = context.getSharedPreferences(BRConstants.PREFS_NAME, Context.MODE_PRIVATE); byte[] bytes = prefs.getString(BRConstants.EXCHANGE_RATES, "{}").getBytes(); if (bytes.length == 0) { return null; }//ww w. ja v a 2s. co m Set<CurrencyEntity> result = null; ByteArrayInputStream byteArray = new ByteArrayInputStream(bytes); Base64InputStream base64InputStream = new Base64InputStream(byteArray, Base64.NO_WRAP); ObjectInputStream in; try { in = new ObjectInputStream(base64InputStream); result = (Set<CurrencyEntity>) in.readObject(); } catch (IOException | ClassNotFoundException e) { e.printStackTrace(); } return result; }
From source file:com.breadwallet.tools.manager.SharedPreferencesManager.java
public static void putAllowSpend(Activity activity, boolean allow) { SharedPreferences prefs = activity.getSharedPreferences(BRConstants.PREFS_NAME, Context.MODE_PRIVATE); SharedPreferences.Editor editor = prefs.edit(); editor.putBoolean(BRConstants.ALLOW_SPEND, allow); editor.apply();/*from w ww . j a v a 2s .c om*/ }
From source file:com.breadwallet.tools.manager.SharedPreferencesManager.java
public static void putIso(Activity context, String code) { SharedPreferences settings = context.getSharedPreferences(BRConstants.PREFS_NAME, 0); SharedPreferences.Editor editor = settings.edit(); editor.putString(BRConstants.CURRENT_CURRENCY, code.equalsIgnoreCase(Locale.getDefault().getISO3Language()) ? null : code); editor.apply();/* w w w .ja v a 2 s. co m*/ }
From source file:com.breadwallet.tools.manager.SharedPreferencesManager.java
public static void putReceiveAddress(Activity ctx, String tmpAddr) { SharedPreferences.Editor editor = ctx.getSharedPreferences(BRConstants.PREFS_NAME, Context.MODE_PRIVATE) .edit();/* w ww . j av a2 s.c om*/ editor.putString(BRConstants.RECEIVE_ADDRESS, tmpAddr); editor.apply(); }
From source file:com.breadwallet.tools.manager.SharedPreferencesManager.java
public static void putGeoPermissionsRequested(Activity activity, boolean requested) { SharedPreferences prefs = activity.getSharedPreferences(BRConstants.PREFS_NAME, Context.MODE_PRIVATE); SharedPreferences.Editor editor = prefs.edit(); editor.putBoolean(GEO_PERMISSIONS_REQUESTED, requested); editor.apply();//from w ww . j ava2 s . c o m }
From source file:com.tesobe.hello_obp.lib.OBPRestClient.java
public static boolean clearAccessToken(Activity activity) { Editor editor = activity.getSharedPreferences(PREF_FILE, 0).edit(); editor.putString(CONSUMER_TOKEN, PREF_NOT_SET); editor.putString(CONSUMER_SECRET, PREF_NOT_SET); consumer.setTokenWithSecret("", ""); return editor.commit(); }
From source file:com.breadwallet.tools.manager.SharedPreferencesManager.java
public static void putFirstAddress(Activity context, String firstAddress) { SharedPreferences prefs = context.getSharedPreferences(BRConstants.PREFS_NAME, Context.MODE_PRIVATE); SharedPreferences.Editor editor = prefs.edit(); editor.putString(BRConstants.FIRST_ADDRESS, firstAddress); editor.apply();/* w w w . jav a 2 s .c om*/ }
From source file:com.breadwallet.tools.manager.SharedPreferencesManager.java
public static List<Integer> getBitIdNonces(Activity activity, String key) { SharedPreferences prefs = activity.getSharedPreferences(BRConstants.PREFS_NAME, Context.MODE_PRIVATE); String result = prefs.getString(key, null); List<Integer> list = new ArrayList<>(); try {//w w w . ja v a 2s. c om JSONArray arr = new JSONArray(result); for (int i = 0; i < arr.length(); i++) { int a = arr.getInt(i); Log.d("found a nonce: ", a + ""); list.add(a); } } catch (Exception e) { e.printStackTrace(); } return list; }
From source file:com.breadwallet.tools.manager.SharedPreferencesManager.java
public static void putPhraseWarningTime(Activity activity, long phraseWarningTime) { SharedPreferences prefs = activity.getSharedPreferences(BRConstants.PREFS_NAME, Context.MODE_PRIVATE); SharedPreferences.Editor editor = prefs.edit(); editor.putLong(BRConstants.PHRASE_WARNING_TIME, phraseWarningTime); editor.apply();//from ww w .ja v a 2s . com }
From source file:com.breadwallet.tools.manager.SharedPreferencesManager.java
public static void putCurrencyListPosition(Activity context, int lastItemsPosition) { SharedPreferences settings = context.getSharedPreferences(BRConstants.PREFS_NAME, 0); SharedPreferences.Editor editor = settings.edit(); editor.putInt(BRConstants.POSITION, lastItemsPosition); editor.apply();//www. j av a2s . c o m }