[英]using exist realm database
I have an existing realm db and I need to read and query it.我有一个现有的领域数据库,我需要阅读和查询它。 I used the following code to assing it as default realm obj so that when ever I call Realm class it points to my db but when I use getDefalutConfiguration() method it doesn't returns my assigned db.
我使用以下代码将其分配为默认领域 obj,因此当我调用 Realm 类时,它指向我的数据库,但是当我使用 getDefalutConfiguration() 方法时,它不会返回我分配的数据库。 instead it returns the defult.realm db which has made internally.
相反,它返回内部创建的 defult.realm db。 this is the colde:
这是寒冷:
Realm.init(this);
RealmConfiguration realConfig = new RealmConfiguration.Builder()
.assetFile("assets\\databases.realm")
.readOnly()
.build();
Realm.setDefaultConfiguration(realConfig);
The asserFile
is used as initial database for the database by copying it to the location according to the configuration, but only if the file does not already exist.通过根据配置将
asserFile
复制到该位置,将asserFile
用作数据库的初始数据库,但asserFile
是该文件尚不存在。 Are you sure that there are not already an existing default.realm
present?您确定还没有现有的
default.realm
吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.