From the course: Android Development Tips

Unlock this course with a free trial

Join today to access over 22,700 courses taught by industry experts.

Create Room DAO classes in Kotlin

Create Room DAO classes in Kotlin - Android Tutorial

From the course: Android Development Tips

Create Room DAO classes in Kotlin

- [Instructor] In last week's tips I described how to start using Kotlin to work with the Room Persistence Library. I created a Kotlin class that would serve as the entity that is a table definition for Room. These columns are translated into the columns in an SQLite table on the device. This week I'll show you how to do that same thing for the data access object. That's the DAO class that defines all of the operations you're going to run with your database. Just as in Java, this will be an interface in Kotlin. I'll right click on the database package, and create a new Kotlin file or class. I'll name it NotesDaoKt, for Kotlin. I'll set the kind to Interface, and click OK. This code is going to look very similar to the Java version. As I did last week with the entity class, I'll do a lot of copying and pasting. I'll go get the DAO annotation, and I'll paste it here above the interface. When I'm prompted to convert to Kotlin code, I'll click Yes. When I'm prompted to add the import for…

Contents