Here is how I have done it in Kotlin.
Inject room db in the activity using DI (Koin).
private val appDB: AppDB by inject()
Then you can simply call clearAllTables()
private fun clearRoomDB() {
GlobalScope.launch {
appDB.clearAllTables()
preferences.put(PreferenceConstants.IS_UPLOADCATEGORIES_SAVED_TO_DB, false)
preferences.put(PreferenceConstants.IS_MEMBERHANDBOOK_SAVED_TO_DB, false)
}
}