1

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
  • 687
  • 7
  • 22
israteneda
  • 614
  • 1
  • 11
  • 21

2 Answers2

2

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
  • 727
  • 1
  • 7
  • 21
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
  • 994
  • 2
  • 11
  • 22