Implementing Room in WhatsPackt
In this section, you will be guided through the practical steps of implementing Room in our chat application. We will begin by setting up Room in Android Studio, followed by creating entities and DAOs and eventually using these components to interact with our database.
Adding dependencies
To start using Room, we first need to include the necessary dependencies in our project. Open your build.gradle
file and add the following dependencies under dependencies
:
dependencies { implementation "androidx.room:room-runtime:2.3.0" kapt "androidx.room:room-compiler:2.3.0" implementation "androidx.room:room-ktx:2.3.0" // optional - Test helpers testImplementation "androidx.room:room-testing:2.3.0" }
The room-runtime
dependency includes the core Room library, while the room-compiler
dependency is...