I found a similar question here and lots of other articles about securing shared preferences but they all come with a warning that-
The certificate you use as the password or “secret” in your code is deleted if the lock screen method or PIN/Pattern is changed.
This is the library people suggesting to use but it has a lot of unresolved issues like if updating to Android Q they are not able to access data.
And EncryptedSharedPreferences can only be used if Min API is 23 (6.0+).
Can someone please suggest if they've found any reliable way to implement encrypt shared preferences?
A new version of EncryptedSharedPreferences (https://developer.android.com/reference/kotlin/androidx/security/crypto/EncryptedSharedPreferences.html) has been released, supporting API Level 21+! So if you're using version 1.1.0-alpha01
and higher, you can have minSdk version 21.
So this is what you have to put to your build.gradle
(app): androidx.security:security-crypto:1.1.0-alpha01
.
Time of typing this, there are newer versions, you can find out more about it here https://developer.android.com/jetpack/androidx/releases/security?authuser=1.
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