0Pricing
Android Academy · Lesson

Queries and Relationships

Query data and relate entities.

Beyond a Single Table

Real apps have related data: a user has many posts, an order has many items. Room models these with foreign keys and the @Relation annotation.

Parameterized Queries

Pass arguments into a @Query with a colon prefix.

@Query("SELECT * FROM users WHERE name LIKE :search")
suspend fun search(search: String): 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