Android App Development
iOS App Development
Flutter 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
Founder. Opencart
Top Partners
Proto Datastore allows us to store custom type data. It uses protocol buffers to store data.
In share preference, we can only save data in key-value. DataStore allows us to store data in key-value pair and in form of object as well.
Proto DataStore is one way of DataStore to save data.
Please check my previous blog for datastore and preferences datastore : Preferences DataStore
We have to create a predefined schema in our project. This schema defines the type of object which we wanna store in Proto DataStore.
Suppose, we wanna save user data. We need to create a .proto file in our project. Lets say User.proto. Directory : app/src/main/proto/
Schema :
NOTE: After creating User.proto file, please rebuild your android project.
Now, define a class which implements Serializer<T> , where T is the type defined in the proto file. This class will define how to read or write data.
T
Use createDataStore() function for creating instance of DataStore.
Get user id :
Get user name :
updateData method is used to save data in Proto DataStore.
To learn more about datastore, check following link : DataStore
Hopefully, this blog will be helpful for you.
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.