2

I am encrypting the shared preferences with this code:

String masterKeyAlias = MasterKeys.getOrCreate(MasterKeys.AES256_GCM_SPEC);

   SharedPreferences sharedPreferences = EncryptedSharedPreferences.create(
       "secret_shared_prefs",
       masterKeyAlias,
       context,
       EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
       EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
   );

   // use the shared preferences and editor as you normally would
   SharedPreferences.Editor editor = sharedPreferences.edit();

Taken from this answer. I would like to know a programmatically method to check if the data is success encrypted. I try the above code to encrypt the shared preferences and don't show me any error.

MohanKumar
  • 960
  • 10
  • 26
israteneda
  • 705
  • 1
  • 14
  • 26

2 Answers2

3

From Android Studio, start Android Device Monitor, go to File Explorer,

and browse "/data/data/< name of your package >/shared_prefs/".

You will find the preferences XML there... and also you can copy it for inspection. you can see the xml contents (encrypted or decrypted)

majid ghafouri
  • 787
  • 2
  • 7
  • 23
2

You can implement the stetho library to view sharepreferences and many more things, such as databases or http calls, from the web browser.

Too easy

http://facebook.github.io/stetho/

Rulogarcillan
  • 1,130
  • 2
  • 13
  • 23