kiwix / kiwix-android

Kiwix for Android
https://android.kiwix.org
GNU General Public License v3.0
861 stars 444 forks source link

Using DataStore instead of SharedPreferences #2688

Open 4shutosh opened 3 years ago

4shutosh commented 3 years ago

Is your feature request related to a problem? Please describe.

SharedPreferences are used for storing key-value pairs in local storage, which is now deprecated.

Describe the solution you'd like

Jetpack DataStore Preferences should be used instead of shared preferences A good article explaining the benefits is here. Its stable version is out, and can be implemented in our app.

Additional context

Files to be modified mainly includes SharedPreferenceUtil for implementing the DataStore

xtanion commented 2 years ago

Hey, may I work on this?

4shutosh commented 2 years ago

Thank you for your interest @xtanion.

Priority: Bugs > Enhancements

Please try to solve one of the bugs floating around first. (good-first-issue && bug) If you cannot yes, you may go ahead and start working on this issue.

xtanion commented 2 years ago

Thanks for the suggestions @4shutosh, I'll look for good-first-issue that I can solve ;).

xtanion commented 2 years ago

I would like to work on this issue for now, can you please assign it to me?

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be now be reviewed manually. Thank you for your contributions.

kelson42 commented 1 year ago

@gouri-panda @mhutti1 Do you confirm that SharedPreferences is really deprecated? Do you confirm that using Jetpack DataStore is the most appropriate replacement?

gouri-panda commented 1 year ago

@kelson42 SharedPreferences hasn't been deprecated yet. But we think it'll be deprecated soon with the alternative of DataStore. DataStore offers many things that SharedPreference lacks. It's a very good idea to replace and use it now.

kelson42 commented 1 year ago

@gouri-panda Thank you for your feedback. I have a bit difficulties to judge how difficult and how much work would be needed. Do you have a few hints/answers?

gouri-panda commented 1 year ago

@kelson42 In a nutshell we have SharedPreferenceUtil class which lets store all the default key and value and we use it over all the functions and tests in our project. We'll be adding a new implementation of DataStore and There'll be some code refactoring in both functions and tests as well. I think it's a little big.

shankarpriyank commented 1 year ago

I can work on this, and I guess it will be a lengthy task, I think it's would be better if we discuss this out before implementing it.

4shutosh commented 1 year ago

Please feel free to list down your questions here @shankarpriyank

shankarpriyank commented 1 year ago

@4shutosh One major thing I have in mind is that, will there not be a migration problem? Like we have different ways to manage migrations of databases in room, do we something like that in this case? Cause let's assume a user has the app with the previous version(with shared preferences installed) and then he updated the app to the datastore version, will that not cause an inconsistency? Maybe break the app too?

kelson42 commented 1 year ago

@gouri-panda @4shutosh @shankarpriyank Considering that: