Searching in Realm

66 Views Asked by At

I have a Realm Class with many columns. I have a search controller in my view where i can search.

 realm = Realm.getDefaultInstance();
    RealmResults<AdressModelRealm> counters;
    RealmQuery<AdressModelRealm> data = realm.where(example.class);
    counters = data.contains("name1",searchtext, Case.INSENSITIVE).or().contains("name2",searchtext, Case.INSENSITIVE).or().contains("name3",searchtext, Case.INSENSITIVE).or().contains("name4",searchtext, Case.INSENSITIVE).findAll();

That works.

Now i would to create the realmsearch on runtime. That´s means, i have 4 Checkbox´s (CB-name1, CB-name2,CB-name, and so on) When CB-name1 und CB-name3 is checked, i will that realm only search in this fields. Can i do that without many if´s ?

The user should decided which columns be consider for search.

0

There are 0 best solutions below