Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert RealmResults object to RealmList?

Tags:

android

realm

I have a RealmResults <Student> object. I want to convert it to RealmList <Student> object. any suggestions?

like image 438
Ezio123 Avatar asked May 08 '15 02:05

Ezio123


4 Answers

RealmList <Student> results = new RealmList<Student>();

results.addAll(realmResultList.subList(0, realmResultList.size()));
like image 99
ChaturaM Avatar answered Nov 01 '22 21:11

ChaturaM


Please try and let me know if this work for you.

RealmList <Student> finalList = new RealmList<Student>();

finalList.addAll(yourRealmResults.subList(0, yourRealmResults.size()));
like image 28
Ralphilius Avatar answered Nov 01 '22 22:11

Ralphilius


RealmResults implements the List interface and so does the RealmList.

RealmList <Student> results = new RealmList<Student>();
results.addAll(realmResultsList);
like image 9
ahmadalibaloch Avatar answered Nov 01 '22 22:11

ahmadalibaloch


Since 0.87.0

  • Added Realm.copyFromRealm() for creating detached copies of Realm objects (#931).

Which allow just return list List<E extends RealmObject>

like image 13
ar-g Avatar answered Nov 01 '22 22:11

ar-g