title: Android - Kotlin - Prepoluate room database
body: <p>I am stuck for 4 days on the same issue so I hope getting some help hear.
  I am trying to load data to a database  through an SQL script but often when I run the app for the first time I have an error :</p>
  <pre><code>java.lang.RuntimeException: Unable to start activity ComponentInfo{small.app.beeroclock/small.app.beeroclock.MainActivity}: java.lang.IllegalStateException: Pre-packaged database has an invalid schema: Country(small.app.beeroclock.db.Country).
       Expected:
      TableInfo{name='Country', columns={country_name=Column{name='country_name', type='TEXT', affinity='2', notNull=true, primaryKeyPosition=0, defaultValue='null'}, country_code=Column{name='country_code', type='TEXT', affinity='2', notNull=true, primaryKeyPosition=1, defaultValue='null'}}, foreignKeys=[], indices=[Index{name='index_Country_country_code', unique=false, columns=[country_code]}]}
       Found:
      TableInfo{name='Country', columns={}, foreignKeys=[], indices=[]}
  </code></pre>
  <p>Thing is I don't undestand the Pre-packaged database has an invalid schema cause my database is based on the Entities :</p>
  <pre><code>@Entity
  data class City(
      @NotNull
      @PrimaryKey
      val name: String,
      @NotNull
      val lat: Double,
      @NotNull
      val lng: Double,
      @NotNull
      val country_code: String
  ) {
  }
  </code></pre>
  <p>And here the the appdatabase class :</p>
  <pre><code>@Database(
      entities = arrayOf(Country::class, Timezone::class, Zone::class, City::class),
      version = 1
  )
  
  
  abstract class AppDatabase : RoomDatabase() {
      abstract fun countryDAO(): CountryDAO
      abstract fun timezoneDAO(): TimezoneDAO
      abstract fun zoneDAO(): ZoneDAO
      abstract fun cityDAO(): CityDAO
  
  }
  
  lateinit var _context: Context
  
  @Volatile
  private lateinit var INSTANCE: AppDatabase
  fun getInstance(context: Context): AppDatabase {
      synchronized(AppDatabase::class.java) {
          if (!::INSTANCE.isInitialized) {
              _context = context
              INSTANCE = Room.databaseBuilder(
                  context.applicationContext,
                  AppDatabase::class.java,
                  &quot;app_database&quot;
              ).addCallback(rdc).fallbackToDestructiveMigration()
                  .build()
              //.addCallback(rdc)
          }
          return INSTANCE;
      }
  }
  
  var rdc: RoomDatabase.Callback = object : RoomDatabase.Callback() {
      override fun onCreate(db: SupportSQLiteDatabase) {
          super.onCreate(db)
          //INSERT INTO `country` VALUES ('AF','Afghanistan')
  //TODO : Issue to insert cities
          try {
              db.beginTransaction()
              _context.assets.open(&quot;sql/timezonedb.sql&quot;).bufferedReader().forEachLine {
                  db.execSQL(it)
              }
              db.setTransactionSuccessful();
              Log.d(&quot;Callback&quot;, &quot;The creation of the db is done&quot;)
          } catch (e: Exception) {
              e.printStackTrace()
              Log.d(&quot;Callback&quot;, &quot;Issue with the database import&quot;)
          } finally {
              db.endTransaction();
          }
  
      }
  
  
      override fun onOpen(db: SupportSQLiteDatabase) {
      }
  }
  </code></pre>
  <p>I guess it is not coming from the sql file itself because if, so I would have a sql error.</p>
  <p>If anyone can highlight me I would really appreciate that :D</p>
  <p>Regardss</p>