scottyab / secure-preferences

Android Shared preference wrapper than encrypts the values of Shared Preferences. It's not bullet proof security but rather a quick win for incrementally making your android app more secure.
1.53k stars 235 forks source link

Value can't be saved when put value after clear() and kill app in background. #106

Open IBeiBei opened 4 years ago

IBeiBei commented 4 years ago

Demo project - MainActivity: @DebugLog public void onGetButtonClick(View v) { final String value = getSharedPref().getString(MainActivity.KEY, null); toast(MainActivity.KEY + "'s, value= " + value); } @DebugLog public void onSetButtonClick(View v) { getSharedPref().edit().clear().commit();// Add this line getSharedPref().edit().putString(MainActivity.KEY, MainActivity.VALUE) .commit(); toast(MainActivity.KEY + " with enc value:" + MainActivity.VALUE

wiztensai commented 4 years ago

in my case, it work if your sintax like this: getSharedPref().edit(true, { clear() })