我正在从资产文件夹中的数据库创建会议室数据库。
database = Room.databaseBuilder(this, AppDatabase::class.java, "x.db")
.createFromAsset("databases/x.db")
.fallbackToDestructiveMigration()
.build()
带有实体类
@Entity(tableName = "x")
data class BibleDatas(
@NotNull @ColumnInfo(name = "age") var name: Int,
@NotNull @ColumnInfo(name = "name") var age: String,
@Nullable @ColumnInfo(name = "saved") var saved: Int
@PrimaryKey(autoGenerate = true) @NotNull @ColumnInfo(name = "id") var id: Int
)
我的资产文件夹数据库具有列名称和年龄,并且保存的列是动态创建的。
但是出现错误提示
Pre-packaged database has an invalid schema:
Expected:
TableInfo{name='x', columns={age=Column{age='age', type='INTEGER', affinity='3', notNull=true, primaryKeyPosition=0, defaultValue='null'}, saved=Column{age='saved', type='INTEGER', affinity='3', notNull=false, primaryKeyPosition=0, defaultValue='null'}, name=Column{age='name', type='TEXT', affinity='2', notNull=true, primaryKeyPosition=0, defaultValue='null'}}, foreignKeys=[], indices=[]}
Found:
TableInfo{name='x', columns={age=Column{age='age', type='INTEGER', affinity='3', notNull=true, primaryKeyPosition=0, defaultValue='null'}, name=Column{age='name', type='TEXT', affinity='2', notNull=true, primaryKeyPosition=0, defaultValue='null'}}, foreignKeys=[], indices=[]}