Introduction
DataStore is a modern persistence solution from Google. It’s part of the Jetpack Libraries. DataStore allows you to store key-value pairs or typed objects with protocol buffers. It’s a replacement for SharedPreferences. DataStore uses Kotlin coroutines and Flow to store data asynchronously, consistently, and transactionally, making read and write operations more performant and safe.
This lesson will introduce you to DataStore and show you how to add it to your project. You’ll learn the difference between DataStore and SharedPreferences and lastly you’ll learn how to save and read data from DataStore.
Your key objectives for this lesson are:
- Understand the purpose of DataStore.
- Understand the difference between DataStore and SharedPreferences.
- Learn how to implement the DataStore read and write operations.
And with that, you’re ready to go!