Use viewModelScope to call the database operations.
Remove Dispatcher.IO context and coroutine scope for @Dao methods.
Room library automatically moves database calls onto a background thread, so you don't explicitly need to move them to a background thread. A suspend @Dao method and a @Query method returning LiveData in Room automatically uses a background thread for database calls. You don't have to explicitly specify the Dispatcher.IO. Room does it for you in generated implementation.
Room library automatically moves database calls onto a background thread, so you don't explicitly need to move them to a background thread. A suspend @Dao method and a
@Query
method returning LiveData in Room automatically uses a background thread for database calls. You don't have to explicitly specify the Dispatcher.IO. Room does it for you in generated implementation.