Is DataStore ready to replace SharedPreferences completely? Including usage in SettingsActivity/PreferenceFragmentCompat ?
Is there any way to see the content of the new files (seems they are in "files/datastore/....preferences_pb" path) ? Via the IDE? Somewhere else? What is the format of these files, anyway?
Is there an equivalent of getDefaultSharedPreferences ? Or I always have to tell which file to use ?
I know you shouldn't create large SharedPreferences files, as it could be inefficient and even cause OOM. Is it true for DataStore too?
Do you know of an example of using it together with the new Splash Screen API, so that it could load which theme the user has chosen in the settings of the app before setting the content of the Activity ?
Is DataStore ready to replace SharedPreferences
completely? Including usage in SettingsActivity/PreferenceFragmentCompat?
It covers quite a lot of aspects. I don't know, though, if the coverage is complete. Regarding UI, there is a nice article by Jordan Hansen covering this.
Is there any way to see the content of the new files
(seems they are in "files/datastore/....preferences_pb" path) ?
Via the IDE? Somewhere else?
Yes, through the Device File Explorer. Open it with View - Tool Windows - Device File Explorer.
What is the format of these files, anyway?
A binary file format. Unfortunately I do not know if there is a viewer for it.
Is there an equivalent of getDefaultSharedPreferences ? Or I always have to tell which file to use ?
Well, as the docs say:
Creates a property delegate for a single process DataStore. This should only be called once in a file (at the top level), and all usages of the DataStore should use a reference the same Instance.
So you should use the same file.
I know you shouldn't create large SharedPreferences files, as it could be inefficient and even cause OOM. Is it true for DataStore too?
A main feature of DataStore is being asynchronous. It was built to overcome inefficiencies of the old preferences api. I did not do any profiling, though.
OK seems it's supported there. Just not sure how to do it. Know of any nice sample of using it there?
No, I'm sorry, nothing besides what's shown in the link (article)
Yes I meant how to read them and view them...
I'm aware of now viewer app, sorry. But as you can see from my code, access is really simple, so if I were to inspect the file, I would probably just iterate over the keys and print the values to console
So I should choose some file that will be used for all (if I use a single file), right?
Yes.
What about the theme&splashScreen question?
I might do a short demo in the future, but as of tight schedule can't say when.
I have some questions about DataStore:
Sorry, I had almost missed your comment. These are very interesting questions. I'll see if I can provide some answers. Please stay tuned.
Hello. Happy to answer some of your questions.
It covers quite a lot of aspects. I don't know, though, if the coverage is complete. Regarding UI, there is a nice article by Jordan Hansen covering this.
Yes, through the Device File Explorer. Open it with View - Tool Windows - Device File Explorer.
A binary file format. Unfortunately I do not know if there is a viewer for it.
Well, as the docs say:
So you should use the same file.
A main feature of DataStore is being asynchronous. It was built to overcome inefficiencies of the old preferences api. I did not do any profiling, though.
Sincerely hope this helps.
No, I'm sorry, nothing besides what's shown in the link (article)
I'm aware of now viewer app, sorry. But as you can see from my code, access is really simple, so if I were to inspect the file, I would probably just iterate over the keys and print the values to console
Yes.
I might do a short demo in the future, but as of tight schedule can't say when.
Too bad.
Please let me know if you add a demo.
for reading check (protoc)
stackoverflow.com/a/70345554/2437655