Pick the fix
A new app stores a refresh token in SharedPreferences in plain text. What's the best fix for 2026?
Hint 1 of 1
Where should the encryption key live?
Choose an answer, then open Show answer below to check it.
Show answer
Answer: A Encrypt it with an AES key from Android Keystore, store the ciphertext in DataStore, and exclude it from backup
Correct. The key stays in secure hardware and the token isn't copied to other devices.
Why not the others?
- B Switch to EncryptedSharedPreferences. That library is deprecated; don't start new code on it.
- C Base64-encode the token. Encoding isn't encryption.
- D Move it to external storage. Other apps or users could read it.