I use the EncryptedSharedPreferences from the androidx.security:security-crypto:1.0.0-alpha02 lib to store some Tokens. If i use prefs.edit().remove("token")).apply()
or prefs.edit().remove("token")).commit()
the token is removed. But if i try to clear the prefs at once with the clear()
method nothing happens.
This call: prefs.edit().clear().commit()
even returns false
.
I get the EncryptedSharedPreferences by using this method:
private fun getPrefs(): SharedPreferences {
val masterKeyAlias = MasterKeys.getOrCreate(MasterKeys.AES256_GCM_SPEC)
return EncryptedSharedPreferences.create(
"myPrefs",
masterKeyAlias,
context,
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
)
}
Do i have to clear the EncryptedSharedPreferences in some other way?
The documentation says (https://developer.android.com/reference/androidx/security/crypto/EncryptedSharedPreferences) :
// use the shared preferences and editor as you normally would SharedPreferences.Editor editor = sharedPreferences.edit();
Update 07.02.2020 I created a bug ticket in the google bugtracker (https://issuetracker.google.com/issues/138314232) but they wont fix it...
This issue fixed from version 1.0.0-rc03. Clear is working fine now. Enjoy!
Refer release note: https://developer.android.com/jetpack/androidx/releases/security#security-crypto-1.0.0-rc03
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With