data - Single Instance of the class, shared by all clients - Easy methods to read-write from Shared preferences - Special editor to make modifications - Read/write operations are on the main thread
Key-value pairs or Typed objects - Uses coroutines/flows to store data asynchronously - Uses protocol buffers to store data - Transactional, consistent data operations - Two different implementations Preferences DataStore Proto DataStore
SharedPreference API - Key-Value pairs to store data, no type safety - No predefined schéma implementation "androidx.datastore:datastore-preferences:1.0.0-beta01" private val Context.userPreferencesDataStore:DataStore<Preferences> by preferencesDataStore(name = "user")
Safe Asynchronous call over Dispatchers.IO - No apply/commit to save changes - Transactional updates - Exposes data through a Flow - Solid error handling support/no random runtime exceptions
custom typed objects - Predefined Schema in .protoc file - Out of the box type safety - Uses protocol buffers as serialization mechanism implementation "androidx.datastore:datastore:1.0.0-beta01"