Android room & database migration

There was a convenient library Sqliteassethelper. It made possible do not write migration scripts from old to new schema version. The library immediately copies the new database file from apk when the new version of your application stating. And versioning of the database was saved.

When an application was migrate to Room, this approach not working with Sqliteassethelper. And if you haven’t had migration scripts, update to new version of the application may be a problem.

But there is a solution:

The internet has a bit of information about this way. What is going here: room removed database tables from specific starting schema versions. When it creates a new schema. When I fill the database with correct new data.

What next: you can start writing migration scripts in the next version, or simply add one more version to #fallbackToDestructiveMigrationFrom argument list.

Enjoy!