接上一篇
React-native Realm 数据迁移
iOS端 没有异常,Android端出现了 Unable to open a realm at path '.management'.
的错误
在stackoverflow中查找,
let nextSchemaIndex = Realm.schemaVersion(Realm.defaultPath);
while (nextSchemaIndex < schemas.length) {
const migratedRealm = new Realm(schemas[nextSchemaIndex]);
nextSchemaIndex += 1;
migratedRealm.close();
}
更换代码为下面,android端口则可正常。
let nextSchemaIndex = Realm.schemaVersion(Realm.defaultPath);
while (nextSchemaIndex < schemas.length) {
const migratedRealm = new Realm({ ...schemas[nextSchemaIndex] });
nextSchemaIndex += 1;
migratedRealm.close();
}
网友评论