我们如何为领域模型字段提供默认值?
例:
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+