I am new to android development. Currently, I would like to encrypt a custom named Shared Preference and integrate with PreferenceScreen but failed to do so. I am using dependencies:
- androidx.security:security-crypto:1.0.0-alpha02 [EncryptedSharedPreference]
- androidx.preference:preference:1.1.0 [PreferenceScreen]
I had tried to research the related information about integration of these 2 features but no related information found.
From my testing, I had an existing encrypted shared preference and tested the following API:
getPreferenceManager().setSharedPreferencesName("MyShared"); //MyShared Is custom named preference.
But it ended up save the preference in plain value.
My Questions:
- Is it possible to integrate these 2 features together in current stage?
- Does PreferenceScreen provide encrypted feature as I am not aware of?
- If I am insist to use EncryptedSharedPreference, will it be better that I create a custom activity look like preference screen?
Use
getPreferenceManager().setPreferenceDataStore(PreferenceDataStore).PreferenceDataStoreprovides the ability to change how preference is loaded/saved.A simple implementation of
PreferenceDataStore: