← Android App Development (Kotlin) learning path
Android App Development (Kotlin) · Module 8 of 10

Local data: Room and DataStore

Store data on the device.

📖 Key ideas

  1. Room is an SQLite abstraction: @Entity, @Dao, @Database.
  2. DAOs define queries: @Query("SELECT * FROM notes").
  3. Room can return Flow so UI updates automatically.
  4. DataStore stores small key-value settings (replaces SharedPreferences).
  5. Use offline-first: cache network data locally.
💡 Real-life example: Room is a filing cabinet in the phone; DataStore is a sticky note for small settings.
RoomSQLite database library
@DaoData Access Object interface
DataStoreModern key-value storage
Offline-firstApp works from local data first