看起来RealmProxy类隐藏了我的RealmObject值,但可以从proxyclass设置。
你可以看到我的模型非常简单。
public class GroupRealm extends RealmObject {
@PrimaryKey
public String id;
@Index
public String name;
public String imageUrl;
public int order;
public GroupRealm parent;
public RealmList<GroupRealm> children;
public RealmList<ContentRealm> contents;
}
这是我设置值的方式(db是一个有效的Realm,一切都在提交正常的事务中):
GroupRealm gr = db.where(GroupRealm.class).equalTo("id",g.GroupID).findFirst();
if(gr==null){
gr = db.createObject(GroupRealm.class,g.GroupID);
}
gr.imageUrl = g.GlyphUrl;
gr.name = g.Title;
gr.order = g.OrderNum;
下面的图片是我查询db后面的内容。(相同的变量名称在代码中不相同)
RealmObject的值不是RealmProxyClass
在我的android.library中,我的RealmObjects被定义为项目,我有必要的插件。
apply plugin: 'com.android.library'
apply plugin: 'realm-android'
在项目级别,我正在设置正确的依赖项:
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath "io.realm:realm-gradle-plugin:0.90.1"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
我没有想法。如果我尝试访问任何内容,我会按预期检索GroupRealm,但通过代理类公开的所有公共属性都返回null!
芜湖不芜
相关分类