Android Realm, request objects by child attribute

I use Realm-Javafor an android application.

I need to query the list MyObject, looking for those that contain the string in MyObject.SubObject_A.ListOfString.

Since Realm does not support the list String, I now use this structure:

-MyObject
----SubObject_A
--------Attribute_A
--------Attribute_B
--------RealmList<RealmString>
----SubObject_B
----OtherStuff

C RealmStringwill be

public class RealmString extends RealmObject {
  public static final String VALUE = "value";
  private String value;
}

How to query for all MyObjectthat contain a given string inside MyObject.SubObject_A.RealmList<RealmString>?

+4
source share
1 answer

You are looking for links to queries . You must do something like this to get it RealmResults<MyObject>.

realm.where(MyObject.class).equalTo("subObject_A.stringList.value", "search string").findAll();

, equalTo, , .

+12

Source: https://habr.com/ru/post/1611944/


All Articles