简体   繁体   中英

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. 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? 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

如果仅要更新几个值而不是迁移整个数据库,则应在应用启动的初始阶段(如启动屏幕中)搜索和更新该特定值。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM