How it works
Preferences DataStore stores key-value pairs; Proto DataStore stores a typed object defined with Protocol Buffers. Both read and write asynchronously with coroutines and expose data as a Flow, so a settings screen updates as soon as a value changes and nothing blocks the main thread, a common cause of freezes with SharedPreferences.
Writes are transactional, so a crash halfway through cannot leave a corrupted file. It is meant for small data: anything with many records, relationships or queries belongs in Room. DataStore also works in Kotlin Multiplatform. It does not encrypt anything by itself, so tokens and other secrets should be encrypted with a key from the Android Keystore.
DataStore pricing
Related terms
More in Mobile apps
Android building blocks