0Pricing
Android Academy · Lesson

Observing Data with Flow

React to database changes reactively.

Reactive Database Reads

Instead of querying once, Room can return a Flow that emits a new value every time the underlying data changes. Your UI updates automatically.

Returning a Flow from a DAO

Declare the return type as Flow<...>. Notice it is not a suspend function.

@Query("SELECT * FROM users ORDER BY name")
fun observeUsers(): Flow<List<User>>

All lessons in this course

  1. Entities and DAOs
  2. The Room Database Class
  3. Queries and Relationships
  4. Observing Data with Flow
← Back to Android Academy