0

我想更改已经存在的领域数据库的领域配置。在我的应用程序中,我一直在使用:

new RealmConfiguration.Builder(this).name("db10").build();

在 Playstore 上发布应用程序后,我发现我可以使用自定义迁移来更改已经存在的数据库,如下所示:

new RealmConfiguration.Builder(context).name("db10"). schemaVersion(0).migration(new CustomMigration()).build();

但我无法更改已经存在的数据库的领域配置。如果我尝试使用新配置打开现有数据库,我会得到:

IllegalArgumentException: Configurations cannot be different if used to open the same file. 

所以我现在要做的是-在具有迁移功能的设备上创建一个新数据库-检查是否有旧数据库-设备上是否有旧数据库将内容复制到新数据库并删除旧数据库

4

0 回答 0