如何在安卓中清除默认领域数据库?我尝试了以下代码,但无法解决deleteRealmFile方法。
方法1:
但是它会报错:
方法1:
try {
Realm.deleteRealmFile(context);
//Realm file has been deleted.
} catch (Exception ex){
ex.printStackTrace();
//No Realm file to remove.
}
我尝试使用配置文件进行删除。
方法2:
try {
Realm.deleteRealm(realm.getConfiguration());
//Realm file has been deleted.
} catch (Exception ex){
ex.printStackTrace();
//No Realm file to remove.
}
但是它会报错:
java.lang.IllegalStateException: It's not allowed to delete the file associated with an open Realm. Remember to close() all the instances of the Realm before deleting its file.