I know that EncryptedSharedPreferences use the android keystore to encrypt preferences securely and that the android keystore is tied to the devices hardware I also read that the keystore cannot be backed up like preferences and databases are. My question is what this means when I am trying to restore my apps settings onto a new device:
Are preferences still backed up in a decrypted manner?
Are they still encrypted and thus unusable on the new device?
should I exclude EncryptedSharedPreferences from backups?
If you locate the
.xmlfile that serves as yourShared Preferencesfile, you'll observe that both thekeyandvalueare encrypted. (Thekeyhere means thekeyyou use when puttingShared Preferences, notMasterKeyfor encyrpting). Therefore, if you back up the file, you will get its encrypted version. Since the new device and thekeyare encrypted, you will not be able to access anything and you probably will reach the default state of allShared Preferences. You should excludeEncrypted Shared Preferencesfrom the backup. If included, there won't be aMasterKeyavailable to decrypt the values on the new device. In conclusion this implies that you won't be able to access any data when installing on a new device.You can review the warning here.
Encrypted Shared Preferences