Android DataStore

DataStore is Google’s new and improved solution for persisting simple pieces of data by using either key-value pairs or protocol buffers for storing typed objects. It does so using Kotlin Coroutines and Flow to make all the transactions asynchronous, making all the data storing and fetching operations more performant and safe! It’s part of the Jetpack set of tools, so it’s also known as the Jetpack DataStore. In this course, learn how to store simple and complex typed data in Jetpack DataStore as well as migrating existing data from Shared Preferences. By Aldo Olivares.

3.8 (4) · 1 Review

Download materials
Save for later
Comments
Share

Learning path

This is part of the Advanced Android Data & Networking learning path. View path.

Who is this for?

Intermediate level Android developers who want to learn about the new Android Jetpack DataStore API. This course will be particularly useful if you want to learn more about how to save data in Android.

Covered concepts

  • Storing Simple Key-value Pairs
  • Storing Complex Data
  • Migrating Existing Data
  • Protocol Buffers

Part 1: Android DataStore

01
Toggle description

Learn how to implement a theme change functionality by storing the current theme in SharedPreferences. Also prepare to develop other parts of the app by enabling auto import in your settings.

Toggle description

Jetpack DataStore is a solution for data persistence that lets you store key-value pairs or typed objects by using protocol buffers. In this episode learn all you need to know about DataStore and the advantages it provides over SharedPreferences.

Toggle description

In the previous episode we stored our theme’s information in SharedPreferences. While this is fine in most cases it is not using DataStore and our course is all about DataStore, right? In this episode start migrating our information to Jetpack DataStore.

Toggle description

Now that you have created your Prefs Datastore it is time to use it. In this episode learn how to read and observe data from Prefs DataStore using your ViewModels.

Toggle description

In this episode, learn how to observe data from Prefs DataStore using your ViewModels.

Toggle description

Reading and observing data from Prefs DataStore is fine but we still need to be able to save information. In this episode learn how to write data to DataStore.

Toggle description

Proto DataStore uses protocol buffers to serialize data. Protocol buffers are Google’s language-neutral and platform-neutral mechanisms for serializing structured data. In this episode start implementing filtering with Proto DataStore.

Toggle description

In order to let DataStore know how to read and write the data type you previously defined, you will need a Serializer. In this episode, create a Serializer for your filter_options.proto file.

Toggle description

Now that your Proto DataStore is ready you need to start using it. In this episode learn how to read the filter options saved in DataStore.

Toggle description

In the last episode of this course add the code to react to filter changes and update the UI accordingly.

Up next

Android & Kotlin
Retrofit and Coroutines
The old way of making network calls with Retrofit utilizes callbacks. In this course, learn how to greatl... more

Instructors

Aldo Olivares

Contributors

Aldo Olivares

Instructor

Adriana Kutenko

Illustrator

Over 300 content creators. Join our team.