Afzal Najam
1 min readMar 17, 2020

--

Is this supposed to be used with withTransaction ?

I have a ViewModel that’s pulling in an object (using Flow) from Room, and then another function that deletes it. It always crashes with:

Cannot access database on a different coroutine context inherited from a suspending transaction

I kind of understand the error but I don’t know how to mitigate it.

--

--

Afzal Najam
Afzal Najam

Written by Afzal Najam

Senior Android Developer @ Doist

No responses yet