reading_notes

Read: 29 - Room

Room

Library

Room provides the following benefits

dependencies {
def room_version = "2.3.0"

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"

// optional - Paging 3 Integration
implementation "androidx.room:room-paging:2.4.0-alpha04"
}

Room Components are mainly

Entities in room

DAO

DAO

Insert

 @Insert(onConflict = OnConflictStrategy.REPLACE)
   public void insertUsers(User... users);

   @Insert
   public void insertBothUsers(User user1, User user2);

Update

   @Update
   public void updateUsers(User... users);

Delete

 @Delete
    public void deleteUsers(User... users);

References