Simple Preferences & Proto DataStore Demo App
Beginner’s friendly step-by-step guide to learn how to use Preferences and Proto DataStore, Room Database is not covered.
8 min readJun 17, 2023
There are a few ways you can store data locally on your Android devices:
- SharedPreferences (replaced by Preferences DataStore)
- Preferences DataStore
- Proto DataStore
- Room Database
SharedPreferences is the old way, which has been replaced by Preferences DataStore due to its shortcomings (e.g. not safe to be called from the UI thread).
In this article, I’m going to share how to store data using both Preferences DataStore and Proto DataStore. Room Database will be covered later in the next article.
Prefer which way to store data?
Preferences DataStore stores data in a simple key-value format. It is usually for a small and simple dataset. If you have a more complex data format, use Proto DataStore.