Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import Room Persistence Library to an Android project

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 don't find which dependencies I should import to my gradle file on my Android project. Someone can give me a hand?

like image 309
Francisco Durdin Garcia Avatar asked May 18 '17 11:05

Francisco Durdin Garcia


People also ask

What is room persistence library?

The Room persistence library provides an abstraction layer over SQLite to allow fluent database access while harnessing the full power of SQLite. In particular, Room provides the following benefits: Compile-time verification of SQL queries.

Is room in Android an ORM?

Is Android Room an ORM? Room isn't an ORM; instead, it is a whole library that allows us to create and manipulate SQLite databases more easily. By using annotations, we can define our databases, tables, and operations.

What is room DB Android?

Room Database is a part of the Android Architecture components which provides an abstraction layer over SQLite which allows for more robust database access while still providing the full power of SQLite. Room is a persistence library, part of the Android Jetpack.


1 Answers

It's possible to find the dependencies on the example codelab for the new architecture components.

Root :

allprojects { repositories {     jcenter()     maven {         url "https://maven.google.com"     } } 

For Room:

  implementation 'android.arch.persistence.room:runtime:1.0.0-alpha1'   annotationProcessor 'android.arch.persistence.room:compiler:1.0.0-alpha1' 

For Lifecycle dependencies:

  implementation 'android.arch.lifecycle:extensions:1.0.0-alpha1'   annotationProcessor 'android.arch.lifecycle:compiler:1.0.0-alpha1' 

Adding Rxjava2 objects as result for our queries:

  implementation 'android.arch.persistence.room:rxjava2:1.0.0-alpha1' 

Test migrations:

  testImplementation'android.arch.persistence.room:testing:1.0.0-alpha1' 
like image 115
Francisco Durdin Garcia Avatar answered Nov 03 '22 18:11

Francisco Durdin Garcia