I recently saw the new feature announced on Google I/O Room Persistence Library to work with Sqlite databases on Android. I have been looking to the official documentation and I
On your project root build.gradle
you have to add Google's maven repository:
allprojects {
repositories {
jcenter()
maven {
// For Room Persistence Library
url "https://maven.google.com"
}
}
}
And then on the build.gradle
of the Module you should add:
compile 'android.arch.persistence.room:runtime:1.0.0-alpha1'
annotationProcessor 'android.arch.persistence.room:compiler:1.0.0-alpha1'
compile 'android.arch.lifecycle:extensions:1.0.0-alpha1'
annotationProcessor 'android.arch.lifecycle:compiler:1.0.0-alpha1'
compile 'android.arch.persistence.room:rxjava2:1.0.0-alpha1'
testCompile'android.arch.persistence.room:testing:1.0.0-alpha1'
Add this if you want to use RxJava2 Publisher
and Flowable
objects as a result of your queries
compile 'android.arch.persistence.room:rxjava2:1.0.0-alpha1'
And finally add also this dependency to test migrations
testCompile'android.arch.persistence.room:testing:1.0.0-alpha1'
Update: The libraries are still marked as Alpha1 so I guess the version number will be updated soon, maybe using have been updated and as definded on the documentation you can use 1.0.+
until there is a final version could be a good idearoom 1.1.1
using this dependencies:
dependencies {
def room_version = "1.1.1"
implementation "android.arch.persistence.room:runtime:$room_version"
annotationProcessor "android.arch.persistence.room:compiler:$room_version" // use kapt for Kotlin
// optional - RxJava support for Room
implementation "android.arch.persistence.room:rxjava2:$room_version"
// optional - Guava support for Room, including Optional and ListenableFuture
implementation "android.arch.persistence.room:guava:$room_version"
// Test helpers
testImplementation "android.arch.persistence.room:testing:$room_version"
}