vicolored vicolored - 5 months ago 22
Android Question

Check two fields with Realm database

How can I create an

and
operation with Realm?

Example I have an object with day and month and I want to check both those fields values.

Something like :

RealmResults<Event> toEdit = realm.where(Event.class)
.equalTo("day", day)
.and
.equalTo("month", month)
.findAll();


But as far as I can tell there is no
and
operator.

Thank you

Answer

Multiple conditions are combined with And unless there's an .or() between them, so it's just:

 RealmResults<Event> toEdit = realm.where(Event.class)
        .equalTo("day", day)
        .equalTo("month", month)
        .findAll();
Comments