I was asked if I knew if Preferences DataStore could use encrypted files. I didn't. As this is a very interesting question, I decided to take a look at the source code. Here's what I found.
To prepare the data store, I used val Context.dataStore by preferencesDataStore("user_preferences").
As you can see, an instance of PreferenceDataStoreSingletonDelegate is returned. Here's the interesting part:
So, next stop: PreferenceDataStoreFactory.create():
So, the final destination is PreferencesSerializer. It overrides two suspending functions, readFrom() and writeTo(). I guess that the changes would need to be made there. In theory the api might be expanded to pass in alternative implementations.
So, I hope you enjoyed this short dig. 😎
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I was asked if I knew if Preferences DataStore could use encrypted files. I didn't. As this is a very interesting question, I decided to take a look at the source code. Here's what I found.
To prepare the data store, I used
val Context.dataStore by preferencesDataStore("user_preferences")
.As you can see, an instance of
PreferenceDataStoreSingletonDelegate
is returned. Here's the interesting part:So, next stop:
PreferenceDataStoreFactory.create()
:So, the final destination is
PreferencesSerializer
. It overrides two suspending functions,readFrom()
andwriteTo()
. I guess that the changes would need to be made there. In theory the api might be expanded to pass in alternative implementations.So, I hope you enjoyed this short dig. 😎