DataStore is a modern data storage solution introduced by Google to replace SharedPreferences for storing small amounts of data in Android applications. It offers better performance, improved data consistency, and is designed to be asynchronous and thread-safe using Kotlin Coroutines and Flow.
Two Types:
Preferences DataStore: Stores key-value pairs without a predefined schema, ideal for simple settings.
Proto DataStore: Uses Protocol Buffers to define a structured schema, ensuring type safety and improved data integrity.
Asynchronous by Design: DataStore leverages Coroutines and Flow, ensuring data read/write operations are efficient and non-blocking.
Data Consistency: DataStore handles data transactions with atomic operations, reducing risks of race conditions and data corruption.
Improved Performance: DataStore writes data asynchronously to files, avoiding UI thread blocking.
Lifecycle Awareness: With Flow integration, data updates are automatically collected in lifecycle-aware scopes, simplifying UI updates.
For lightweight data like user preferences, settings, or app configurations.
When data consistency, thread-safety, and performance are priorities.
This is an introductory video for the new project which is based on Datastore - A database to store data in the form of Key-Value pairs. We will make a Local Authentication System using Datastore which itself is an important feature for a local application.
In this video we will work on creating the repository which has the required keys, a function to save the data to the Datastore and a flow variable to read the data.
In this video we will work on initializing the Datastore, which we are going to achieve using Manual Dependency injection.
In this video we will work on creating the view model and updating the repository.
In this video we will finalize our app by completing our repository and view model and finally connect all the dost to make the app working.