I'm using Android Room with RxJava
dependencies {
implementation 'androidx.room:room-rxjava2:2.1.0-alpha02'
}
I need to get Completable from parameterized deletion methods, I thought this feature is added as of 2.1.0? ex.
@Query("DELETE FROM message_table WHERE uid = :id")
Completable delete(String id);
@Query("DELETE FROM message_table")
Completable deleteAll();
Still throws error: Deletion methods must either return void or return int (the number of deleted rows).
As the error message is trying to tell:
With @Query
, you have to change the returned data-type from Completable
to int
or void
.
The Completable
would need to subscribe to another method, which runs the method of the Dao
:
Completable
.fromAction(aMethodWhichCallsDao)
.subscribeOn(Schedulers.single())
.subscribe();
Or use the @Delete
annotation, as @Commonsware suggested (in case this works as advertised).