Bachlet Tansime Bachlet Tansime - 1 year ago 106
Android Question

List<Object> Or RealmList<RealmObject> on Realm Android

I need a

using Realm. I tried
but it doesn't work because
is abstract.

Answer Source

Christian from Realm here. You can only save objects that extend RealmObject inside a Realm. This is because Realm is not a schemaless database. We do require a schema and that schema is defined by your objects that extend RealmObject. We use RealmList because it abstracts away the communication with the underlying core database, but it implements the List interface.

This means that

public class Foo extends RealmObject {
  private List<Object> objects;  // not legal
  private RealmList<Object> objects;  // not legal 
  private RealmList<RealmObject> objects; // not legal

public class Foo extends RealmObject {
  private RealmList<Foo> objects; // legal

List<Foo> reference = foo.getObjects(); // Legal
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download