This course is available as part of the raywenderlich.com Professional subscription. To learn more click here
Pro

Android DataStore

Apr 20 2021 · Video Course (44 mins) · Intermediate

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.

4/5 1 Rating

Version

  • Kotlin 1.4, Android 6, Android Studio 4

Android DataStore

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.

1

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.

2

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.

3

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.

4

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

5

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.

6

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.

7

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.

8

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.

9

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

10

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

Contributors

Comments