Blazej SLEBODA
Blazej SLEBODA

Reputation: 9915

How to populate a room database when migrating from version A to B

I have a room database version A and need to migrate to version B. The migration will create a new table with. The table must be prepopulated a definined by author of an app.

How to populate a new table with a given record when migrating from version A to version B of a room database?

Upvotes: 0

Views: 92

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006604

In your Migration, insert the row using insert() or execSQL() on the SupportSQLiteDatabase handed to your migrate() function. Do this after having used execSQL() to create the new table.

Upvotes: 2

Related Questions