Questions tagged [encrypted-shared-preference]
23 questions
48
votes
5 answers
AndroidX Security EncryptedSharedPreferences v1.1.0 /w API 21 issue
I decided to use new EncryptedSharedPreferences from AndroidX Security library. Since the app is supporting API 21 and higher, I decided to try out this new v1.1.0-alpha02 version, since it supports API 21+
So, I succeded to make the implementation…

aherman
- 900
- 1
- 8
- 16
26
votes
7 answers
How to create masterKey after MasterKeys deprecated in Android
I am using the following code to store some information encrypted in my app.
val masterKey = MasterKeys.getOrCreate(MasterKeys.AES256_GCM_SPEC)
val sharedPreferences = EncryptedSharedPreferences.create(
"secret_shared_prefs",
…

Endre Olah
- 875
- 2
- 9
- 25
25
votes
2 answers
Getting KeyStoreException and GeneralSecurityException by using EncryptedSharedPreferences, how can I solve those?
Background
On one of the apps I work on, I store important stuff (tokens) into EncryptedSharedPreferences (taken from here and here):
/** a hardware-encrypted based shared preference (for the values).
* Note that it is a bit slow, so it's better to…

android developer
- 114,585
- 152
- 739
- 1,270
9
votes
2 answers
What key alias need to use in EncryptedSharedPreferences?
how can I use key alias in Encrypted sharedprefernces?
below is my Encrypted shared preference
KeyGenParameterSpec spec = new KeyGenParameterSpec.Builder(
DEFAULT_MASTER_KEY_ALIAS,
…

Kousalya
- 700
- 10
- 29
9
votes
6 answers
Secured Android SharedPreferences Error: 'Caused by: java.lang.RuntimeException: Field keySize_ for...'
In an Android Kotlin project, I implemented EncryptedSharedPreference feature based on this link using the androidx.security library and it worked well in debug mode. But in release mode, I keep getting this error
…

CanCoder
- 1,073
- 14
- 20
4
votes
3 answers
How to implement encrypted sharepreferences
How to implement encrypted sharepreferences in my android java apps using https://developer.android.google.cn/reference/androidx/security/crypto/EncryptedSharedPreferences? I dont know how to implement it, anyone can help?

angeline_1028
- 51
- 1
- 2
4
votes
1 answer
Unable to access EncryptedSharedPreferences from other activities
First Activity
try {
masterKeyAlias = MasterKeys.getOrCreate(MasterKeys.AES256_GCM_SPEC);
sharedPreferences = EncryptedSharedPreferences.create(
"secret_shared_prefs",
masterKeyAlias,
…

bliss
- 336
- 2
- 8
3
votes
2 answers
security-crypto: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent
Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent. Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent…

Rohan Chavda
- 63
- 1
- 4
3
votes
0 answers
Encrypted Shared preferences causes ANR on Android 9 and Android 10
I am using Encrypted shared preference to encrypted the preferences data. I am using it in the following way:
val masterKey = MasterKey.Builder(context)
.setKeyScheme(MasterKey.KeyScheme.AES256_GCM)
.build()
…

nilkash
- 7,408
- 32
- 99
- 176
3
votes
0 answers
Does Android Keystore and “Clear data” action of the “Settings” app are related?
I am working on a system app where I am storing some sensitive data in EncryptedSharedPreference. I realise that my app is not working as expected if I do clear data of android Settings app.
That is happening because if I try to get the instance of…

GarryCyber
- 31
- 3
2
votes
0 answers
Using EncryptedSharedPreferences gives error Protocol message contained an invalid tag (zero)
When executing this code on a real device
String masterKeyAlias = masterKeyAlias = MasterKeys.getOrCreate(MasterKeys.AES256_GCM_SPEC);
SharedPreferences settings = EncryptedSharedPreferences.create(
"encrypted_preferences",
…

Mathias Rönnlund
- 4,078
- 7
- 43
- 96
2
votes
1 answer
Android API 21 Create Custom Master Key
I'm trying to create an encrypted SharedPreferences implementation but the example given in the Android website is for API 23 and above. Specifically, the problem is creating a master key using this code is…

kobowo
- 2,529
- 2
- 24
- 37
2
votes
1 answer
EncryptedSharedPreferences isUserAuthenticationRequired not working properly
I am using EncryptedSharedPreferences to store encrypted data.
val biometricManager = BiometricManager.from(this)
val hasFingerprint = biometricManager.canAuthenticate() == BiometricManager.BIOMETRIC_SUCCESS
val advanceSpec =…

Ismail Shaikh
- 482
- 4
- 13
1
vote
1 answer
EncryptedSharedPreferences as credentials store
Is it ok to store login credentials in EncryptedSharedPreferences or is it better to use something like the KeyStore.

froots
- 53
- 3
1
vote
0 answers
How to check in Android app that it is using Encrypted Shared Preference and safely migrate to it programmatically
I am working in a project where I have to migrate to Encrypted shared preference refer this link more for Encrypted Shared Preference. I have implemented the pref successfully but my issue is if the shared pref file is already existed it won't…

Pankaj
- 7,908
- 6
- 42
- 65