android / codelab-android-datastore

Apache License 2.0
228 stars 105 forks source link

Migrate to Jetpack Proto Data Store from Shared Preferences when you have more than 300 Preferences in your android app? #26

Open gb103 opened 3 years ago

gb103 commented 3 years ago

Shared Preferences are used heavily into my application, they are more than 300s of every possible data types such as int, boolean, String etc etc.

Now I want to migrate into Jetpack Proto Data store, the all the tutorials which I have tried define all the preferences into .proto file and then retrieve the data from Data Store and provides a FLOW object of the class in which all possible preferences are defined.

The class structure which I define into proto, is used to create Serializer as well into Flow object of the retrieved value, so my QUESTION is,

Do I need to define all the 300+ preferences into a single file first and then use them (It would require me to lots of code to write into each places wherever shared prefs is used) OR is there any better way of migration ?