[英]realm android - how to update specific tables or values on migration without changing the rest
I have changed realm database file in assets and I'd like to make some changes in the current db but all the rest should remain the same so I can't deleteOnMigrationNeeded. 我已更改资产中的领域数据库文件,并且想在当前数据库中进行一些更改,但所有其他内容应保持不变,因此我无法删除OnMigrationNeeded。 I need to update only one table and only specific values in another. 我只需要更新一个表,而只更新另一个表中的特定值。 How can I access the new realm in Migration.class to retrieve new values from there? 如何在Migration.class中访问新领域以从中检索新值? Or how I can solve my problem generally? 还是我通常可以解决我的问题?
This is the way config looks: 这是配置的样子:
RealmConfiguration config = new RealmConfiguration.Builder()
.name("data.realm")
.schemaVersion(1)
.migration(new Migration())
.assetFile("data.realm")
.build();
"migrate" method in Migration.class is now empty Migration.class中的“ migrate”方法现在为空
如果仅要更新几个值而不是迁移整个数据库,则应在应用启动的初始阶段(如启动屏幕中)搜索和更新该特定值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.