- Is it a good practice to store confidential user data like passwords, tokens, etc as shared preferences?
- Will they be secure?
- Are there any other options?
I want these data to be accessed from any activity of my app.
I want these data to be accessed from any activity of my app.
Some users would say you probably shouldn't.
But I would say yes, in private mode, with highly encrypted data.
It's not 100% safe on rooted devices. But if the Encryption Algorithm is strong enought, don't worry.
If you are using strong encryption algorithm for storing usernames, passwords in Shared Preferences, it will help you to protect them from malicious user. You have to use the Shared Preferences in PRIVATE mode so that no other activity outside you APP can access that data.
You can use javax.crypto.Cipher class. This class provides access to implementations of cryptographic ciphers for encryption and decryption.
Use this link to understand the DES and AES algorithms :