Skip to the content.

Read: 29 - Room

Overview: Saving data with Room

Room is a persistence library, part of the Android Architecture Components. It makes it easier to work with SQLiteDatabase objects in your app, decreasing the amount of boilerplate code and verifying SQL queries at compile time.

Save data in a local database using Room

implementation “androidx.room:room-runtime:$room_version” annotationProcessor “androidx.room:room-compiler:$room_version”

// optional - RxJava2 support for Room implementation “androidx.room:room-rxjava2:$room_version”

// optional - RxJava3 support for Room implementation “androidx.room:room-rxjava3:$room_version”

// optional - Guava support for Room, including Optional and ListenableFuture implementation “androidx.room:room-guava:$room_version”

// optional - Test helpers testImplementation “androidx.room:room-testing:$room_version” }

Defining entities in Room

Defining data using Room entities

Define relationships between objects

Accessing data with Room

Accessing data using Room DAOs