Native Shopify Mobile App with 20 new features
Kickstart your hyperlocal marketplace in Corona pandemic with a starter guide
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 184.108.40.206 release ready!
Owner and Founder. Opencart
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*
Save my name email and website in this browser for the next time I comment.
Be the first to comment.
Excellent work, fast, good quality and understood the brief perfectly! Quick responses developing the project and very good cooperation. I suggest to anyone.
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.