gpt4 book ai didi

android确实迁移到房间需要卸载应用程序

转载 作者:行者123 更新时间:2023-11-29 00:56:28 25 4
gpt4 key购买 nike

我们的应用程序的数据库版本为 14,并使用了 android sqllite 帮助程序。现在我们开始使用房间数据库并将所有数据库内容迁移到房间。我们已经定义了从 1_2、2_3 .. 到 13_14 的所有迁移,并为所有这些提供了构建

.databaseBuilder(
app,
Database::class.java,
"my.db"
).addMigrations(arrayOf(
MIGRATION_1_2,
MIGRATION_2_3,
.....
MIGRATION_10_11,
MIGRATION_11_12,
MIGRATION_12_13,
MIGRATION_13_14
))
.build()

这是正确的做法吗?如果我安装了 DB 版本 14 的应用程序的非房间版本,并且我尝试将其更新为具有相同数据库版本 14 的应用程序的房间版本,我收到错误:

java.lang.IllegalStateException: Room cannot verify the data integrity. Looks like you've changed schema but forgot to update the version number. You can simply fix this by increasing the version number.

最佳答案

您只需添加从现有 SQLite 数据库到 Room 管理的数据库的迁移。这应该是一个空的“什么都不做”的迁移。这是必需的,这样 Room 才能很好地与您现有的数据库配合使用。

关于android确实迁移到房间需要卸载应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54447043/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com