Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Room with RxJava3

Is there a way to work with Room database with RxJava3?

the problem that when i try to return Observable or Single from Room Query it shows me the error below:

error: Not sure how to convert a Cursor to this method's return type public abstract io.reactivex.rxjava3.core.Single<java.util.List<com.osama.movieshow.data.movie.Movie>> getAllFavorites();

My Room query:

@Query("select * from favorites") fun getAllFavorites():Single<List<Movie>>

and i'm importing Single from import io.reactivex.rxjava3.core.Single

like image 645
iosamammohamed Avatar asked Mar 06 '20 15:03

iosamammohamed


People also ask

Is room orm an Android?

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.

Does room use SQLite?

Room is a persistent library that is part of the Android jetpack. It is built on top of SQLite.

What is Androidx room?

room. Kotlin |Java. Room is a Database Object Mapping library that makes it easy to access database on Android applications. Rather than hiding the details of SQLite, Room tries to embrace them by providing convenient APIs to query the database and also verify such queries at compile time.


1 Answers

Room now supports Rxjava3. Use the dependency below;

implementation "androidx.room:room-rxjava3:2.3.0-alpha02"
like image 175
Ehma Africa Avatar answered Oct 04 '22 19:10

Ehma Africa