Difference between RealmResults vs RealmList?

I would like to know what is the difference between RealmResults and RealmList.

The only difference I see is that realmlist is to input data, while RealmResults is to run a query.

Thanks

Upvotes: 8

Views: 2280

Answers (1)

A. Steenbergen
A. Steenbergen

Reputation: 3440

Please see the documentation here and here. Especially this part:

RealmList is used to model one-to-many relationships in a RealmObject.

RealmResults are always the result of a database query. RealmList can be used inside of a RealmObject to define One-To-Many relationships (RealmResults can't).

Also this part:

RealmList has two modes: A managed and non-managed mode. In managed mode all objects are persisted inside a Realm, in non-managed mode it works as a normal ArrayList.

A RealmList can be non-managed, thus act like a normal ArrayList, whereas RealmResults is a "window" into the database. Objects are not copied and put into the RealmResults, they are only referenced.

In short RealmResults are always a product of a database query, whereas RealmLists don't have to be.

Upvotes: 14

Related Questions