0

I use rxjava and room for below code, but I always get the error:

java.lang.IllegalStateException: Cannot access database on the main thread since it may potentially lock the UI for a long period of time.

compositeDisposable.add(dataManager.deleteAllNotes()
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe({
                getMvpView()!!.deleteOldDataFromOldUserSuccess()
            }, {
                it.printStackTrace()
            }))

override fun deleteAllNotes(): Completable = mDbHelper.deleteAllNotes()

Please help me.

Tung Tran
  • 2,885
  • 2
  • 17
  • 24
  • Check this SO: https://stackoverflow.com/questions/54729144/why-does-room-delete-operationwith-rxjava-gives-ui-thread-error-even-specifyin – Sanlok Lee Feb 27 '19 at 19:53
  • @Zoe No duplicate, this is combine rxjava and room – Tung Tran Feb 27 '19 at 20:06
  • Worth to check, https://stackoverflow.com/questions/54729144/why-does-room-delete-operationwith-rxjava-gives-ui-thread-error-even-specifyin – blackkara Feb 27 '19 at 22:45

0 Answers0