【问题标题】:Does `deleteRealmIfMigrationNeeded()` always delete the data? Or only when there is an RealmMigrationNeededException?`deleteRealmIfMigrationNeeded()` 是否总是删除数据?还是仅在出现 RealmMigrationNeededException 时?
【发布时间】:2019-07-15 05:22:54
【问题描述】:

https://realm.io/docs/javascript/latest/#opening-realms 领域文档说

deleteRealmIfMigrationNeeded: delete the Realm if migration is needed; this is useful under development since the data model might change often

RealmConfiguration.java,它说

 * Setting this will change the behavior of how migration exceptions are handled. Instead of throwing a
 * {@link io.realm.exceptions.RealmMigrationNeededException} the on-disc Realm will be cleared and recreated
 * with the new Realm schema.

所以我的问题是,deleteRealmIfMigrationNeeded() 是否总是在迁移时删除数据库?还是只有在迁移失败时才删除?

【问题讨论】:

  • 当您更改领域类结构时,它会删除架构。
  • @RajasekaranM 谢谢。如果您发布答案,我会将其标记为已接受。

标签: android realm realm-migration


【解决方案1】:

deleteRealmIfMigrationNeeded() 将在您更改领域类结构时删除应用架构。否则它不会删除你的架构。

【讨论】:

    猜你喜欢
    • 2011-09-19
    • 1970-01-01
    • 2014-07-05
    • 1970-01-01
    • 2017-11-30
    • 1970-01-01
    • 2014-01-24
    • 2011-02-18
    • 1970-01-01
    相关资源
    最近更新 更多