如何设置 Realm 领域字段的默认值?



我们如何为领域模型字段提供默认值?

例:

class Demo extends RealmObject{
private String id; // I want to set this id to a uuid 
private boolean isVisibile; // set this to default as true              
}
class Demo extends RealmObject{
public Demo() {
id = UUID.randomUUID().toString();
isVisible = true;
} 
@PrimaryKey
private String id; // I want to set this id to a uuid 
private boolean isVisibile; // set this to default as true              
}

应该工作 领域 2.0+

相关内容

  • 没有找到相关文章

最新更新