From the course: Complete Guide to Android Development with Kotlin for Beginners

Unlock the full course today

Join today to access over 24,900 courses taught by industry experts.

Retrieve data with Room

Retrieve data with Room

- [Instructor] Room queries have the following characteristics. First, they're based on raw SQL statements, which means you'll be working with variations of the Select statement, and we'll look at a few examples momentarily. Next, they can either be static or dynamic. During runtime, you can determine what values to query the database against. Third, the results are returned to you as objects, not cursors. This makes it easier to work with. And finally, they can be observable. You have the option of configuring Room to notify you of changes to your underlying database tables using either Arch Java, LiveData, or Kotlin coroutines. As I mentioned, Room relies on raw SQL statements to generate the needed code to query your database. In this first example, we're simply selecting all fields from all rows of the Emails table in the database. This is one of the most basic select statements we can have. Now we're using the Where clause to potentially restrict the number of records returned…

Contents