How can I reset room db database schema if I don't want to increment the version?

225 Views Asked by At

My app is getting the following error:

Room cannot verify the data integrity. Looks like you've changed schema but forgot to update the version number. You can simply fix this by increasing the version number.

I don't want to increase the version since the app I'm developing is not yet released. What should I do to prevent this error?

2

There are 2 best solutions below

3
Gavin Wright On BEST ANSWER

Just clear the app data after changing the schema.

0
darshan On

If you do not care about the existing data in the Room DB, you can clear the tables like this:

viewModelScope.launch {
    yourRoomDBInstance.clearAllTables()
}