dimanche 22 novembre 2015

Realm Query Android

I'm getting started in using Realm in my android project..

everything was going well.. But I was trying to filter data but I couldn't.

I want to make a query like this:

SELECT * FROM messages WHERE (fromId='id1' AND toId='id2') OR (fromId='id2' AND toId='id1');

Here's my code :

RealmResults<com.intcore.android.tawasol.Message> results =
            realm.where(com.intcore.android.tawasol.Message.class).beginGroup().equalTo("fromId", fromId).equalTo("toId", toId).endGroup().or().
    beginGroup().equalTo("fromId", toId).equalTo("toId", fromId).endGroup().findAllSorted("date", true);

but this returns only 1 result.. it should return 2 results.

Any Idea?

Aucun commentaire:

Enregistrer un commentaire