There is an object:

public class Contact extends RealmObject implements Serializable { @PrimaryKey private String id; private String displayName; private RealmList<Phone> phone; private RealmList<Email> email; private RealmList<Note> notes; private RealmList<Address> addresses = new RealmList<Address>(); private RealmList<IM> imAddresses; private Organization organization; private int status = -1; private String photo; } 

For example, I have a phone number that is stored in the Phone object and the one in the RealmList<Phone> phone list.

The Phone object looks like this:

 public class Phone extends RealmObject implements Serializable { private String number; private String type; public String getNumber() { return number; } public void setNumber(String number) { this.number = number; } public String getType() { return type; } public void setType(String type) { this.type = type; } } 

Question: how can I get the object itself by the phone number that is contained in the Phone in the private String number field.

    1 answer 1

    Apparently you need to do something like this :

     String numberToSearch = "8-800-800-80-80"; Contact contact = Realm.where(Contact.class).equalTo("phone.number", numberToSearch).findFirst(); 
    • I looked at the documentation, tried your option, but for some reason it does not work. - Kirill Stoianov
    • one
      Found an error, incorrectly submitted the numberToSearch string, everything works! - Kirill Stoianov