Mehdi Haghgoo
11/27/2021, 11:44 AMjava.lang.IllegalStateException: Cannot access database on the main thread since it may potentially lock the UI for a long period of time.I'm doing all insertions in coroutine contexts like:
fun removeMessage(message: Message) = viewModelScope.launch{
repository.remove(message)
}
joadar
11/27/2021, 11:51 AMK Merle
11/27/2021, 12:03 PMdao
function to be suspendable?agrosner
11/27/2021, 12:58 PMagrosner
11/27/2021, 12:58 PMMehdi Haghgoo
11/27/2021, 1:08 PMMehdi Haghgoo
11/27/2021, 1:09 PMAdrian Devezin
11/27/2021, 2:03 PMlaunch(<http://Dispatchers.IO|Dispatchers.IO>) { // code }
. You should inject your dispatchers tho.Adam Powell
11/27/2021, 3:39 PMagrosner
11/27/2021, 3:44 PMAdam Powell
11/27/2021, 3:56 PM