0

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.

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Metti
  • 85
  • 1
  • 8
  • 1
    you need to create overloaded function for that taking inputs as column name, for one ,two three and four searches , in this way no matter which two check boxes you have selected you can get desired result... P.S. For the next time please do not ask for solutions directly ,As you are new therefore I would want to let you know you cannot ask for solutions directly you should do something and then if any problem occurs then ask. – Sara Tirmizi Sep 28 '18 at 05:57
  • 1
    Thanks for your help, i have found the solution with RealmQuery Class – Metti Sep 28 '18 at 06:59
  • @Metti please post your solution to help anyone needing this ;) – Maelig Jan 07 '19 at 15:03

0 Answers0