private void saveSecure() { // Restore preferences SharedPreferences settings = mContext.getSharedPreferences(PREFS_NAME, 0); ObscuredSharedPreferences obscuredSharedPreferences = new WheelmapObscuredSharedPreferences(mContext, settings); SharedPreferences.Editor editor = obscuredSharedPreferences.edit(); editor.putString(API_KEY, mApiKey); editor.putBoolean(LOGGED_IN, mIsLoggedIn); editor.putString(E_MAIL, mEmail); // Commit the edits! editor.commit(); }
private void load() { // Restore preferences SharedPreferences settings = mContext.getSharedPreferences(PREFS_NAME, 0); ObscuredSharedPreferences obscuredSharedPreferences = new WheelmapObscuredSharedPreferences(mContext, settings); try { mApiKey = obscuredSharedPreferences.getString(API_KEY, ANONYMOUNS_ACCESS_API_KEY); mEmail = obscuredSharedPreferences.getString(E_MAIL, ""); mIsLoggedIn = obscuredSharedPreferences.getBoolean(LOGGED_IN, false); } catch (RuntimeException e) { mApiKey = null; mEmail = null; mIsLoggedIn = false; saveSecure(); } }