Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between RealmResults vs RealmList?

Tags:

android

realm

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

like image 696
Sergio Antonio Snchez Camarero Avatar asked Jun 10 '16 10:06

Sergio Antonio Snchez Camarero


1 Answers

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.

like image 82
A. Steenbergen Avatar answered Oct 15 '22 17:10

A. Steenbergen