Android App Development
iOS App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 3.0.3.7 release ready!
Deniel Kerr
Owner and Founder. Opencart
Top Partners
Jetpack DataStore is a new data storage solution and an alternative improvement upon Shared Preferences.
Jetpack DataStore library uses Kotlin coroutines and Flow for easier asynchronous reads and writes.
This library allows you to store key-value pairs or typed objects with protocol buffers.
Protocol buffers are Google’s extensible mechanism for serializing structured data.
There are different approaches in DataStore :
If you are interested to use Jetpack DataStore for storage in your application then this blog will help you to achieve your goal.
First, start with adding DataStore dependency in your Gradle file
if you want to use Proto DataStore, don’t forget to add the below dependency :
if you are using proto DataStore schema is defined in the proto file on app/src/main/proto/ directory.
Context.createDataStore() extension function is used to create an instance of Preferences DataStore with a mandatory name parameter which is the name of the Preferences DataStore.
Here two parameters fileName is the name of the file on app/src/main/proto/ which stores the data and serializer is the name of the serializer class which is CustomerSerializer in my case.
preferencesKey() is used with key for each value that needs to be store in DataStore.
edit() function is to updates the data in a DataStore.
For updating the stored data object use updateData() function.
Your email address will not be published. Required fields are marked*
Name*
Email*
Save my name email and website in this browser for the next time I comment.
Be the first to comment.
We use cookies to personalize your experience. By continuing to visit this website you agree to our use of cookies. Learn more about privacy policy
We've bought a Shopware Extension which is a hybrid App, which we can now offer in the Google Play Store and the IOS App Store. I'am still impressed how fast and how sharp the support team leads us through every process of the App-Store clarification. Very fast and useful response.
Markus Walter
Founder, Das Apartment Living
USA
India
Global
Name
Email
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.