From the course: Android Development Essential Training: Manage Data with Kotlin

Unlock the full course today

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

Define a database table with Room

Define a database table with Room

From the course: Android Development Essential Training: Manage Data with Kotlin

Start my 1-month free trial

Define a database table with Room

- [Instructor] So far, this app has saved data locally in text files using JSON formatting, but you can make local data storage more robust and flexible with a relational database. The Android SDK includes everything you need to work with SQLite, and the recent introduction of the Room architecture component makes working with databases easier than ever before. First, I'll add some required dependencies for Room into my Gradle build file. This is the build.gradle file for the app module, and I'll place my cursor down here at the end of my dependencies, and I'll declare a variable that I'll room_version, and I'll set it to the most recent version of Room as of this recording, 2.1.0. Then I'll add a couple of implementation lines. The first one will be androidx.room:room-runtime, and that'll use that variable. Now I'll duplicate that line, and this one will be room-ktx, for Kotlin. And finally, I'll add an annotation processor, with K-A-P-T, and remember we added an applied plugin…

Contents