Save User State

Sep 10 2024 · Kotlin 1.9, Android 14, Android Studio Koala | 2024.1.1

Lesson 05: Set up a Room Database

Demo: Creating Entities

Episode complete

Play next episode

Next

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

In this section, you’ll walk through how to create entities for your Room database.

import androidx.room.Entity
import androidx.room.PrimaryKey
import kotlinx.serialization.Serializable

@Entity(tableName = "notes")
@Serializable
data class NoteEntity(
  @PrimaryKey(autoGenerate = true)
  val id: Int = 0,
  val title: String,
  val description: String,
  val timestamp: Long,
  val priority: String,
  val noteLocation: String
)
@Database(entities = [NoteEntity::class], version = 1)
abstract class DevScribeDatabase: RoomDatabase() {
}
See forum comments
Cinema mode Download course materials from Github
Previous: Introduction to Tables & Entities Next: Introduction to Data Access Objects