Migration from SharedPreferences to EncryptedSharedPreferences in Android
Add the following dependency to your module-level build.gradle
The existing implementation of PreferenceManager.java
The new implementation with EncryptedSharedPreferences
Add below methods to PreferenceManager.java which transfers all the existing prefs to encrypted shared prefs.
Call migrateToEncryptedSharedPreferences() on app start to perform migration from SharedPreferences to EncryptedSharedPreferences.
Make sure once the migration is completed successfully keep some pref which will indicate whether migration is pending or completed in order to avoid executing migration each time app starts.