From the course: Building an Android App with Jetpack Libraries

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Define an SQLite database with Room

Define an SQLite database with Room - Android Tutorial

From the course: Building an Android App with Jetpack Libraries

Start my 1-month free trial

Define an SQLite database with Room

- After you create your entity classes, your DAO interfaces, and any required type converters. You're ready to create your Room Database definition. I'll create a new Kotlin class in my data package and I'll name it, Appdatabase. This could be any name you like. This class will extend a class named Roomdatabase, and it's a class. So I'll put in the parentheses at the end. This class also has to be abstract. It's up to the room library to generate the concrete class that you'll use at runtime. I also need to mark this class with a couple of annotations. I'll start with the database annotation, and I'll use the entities property to indicate which entities are part of the database structure. This is a common delimited list that goes between a couple of square brackets. I only have one entity, note entity and I'll pass in note entity, colon, colon class. Next, I need to indicate the version number for this database structure.…

Contents