Как то так:
fun databaseBuilder(context: Context): MyAppDatabase {
return Room.databaseBuilder(
context.applicationContext,
MyAppDatabase::class.java,
"MyApp.db"
).addCallback(object : RoomDatabase.Callback() {
override fun onCreate(db: SupportSQLiteDatabase) {
super.onCreate(db)
// create code...
}
}).addMigrations(
object : Migration(1, 2) {
override fun migrate(database: SupportSQLiteDatabase) {
insertFromCVS(context, database) // доступен context
}
}).build()
https://developer.android.com/training/data-storag...