Как установить значения по умолчанию для полей в области? - PullRequest
0 голосов
/ 28 мая 2018

Как мы можем задать значение по умолчанию для поля модели области?

Пример:

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              
}

1 Ответ

0 голосов
/ 28 мая 2018
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              
}

Должен работать Realm 2.0 +

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...