How to convert RealmResults<Object> to List<Object>

前端 未结 3 1382
轻奢々
轻奢々 2021-01-04 02:54

I have RealmResults that I receive from Realm like

RealmResults stepEntryResults = realm.where(StepEntry.class).findAll();
         


        
3条回答
  •  无人及你
    2021-01-04 03:29

    The answer by @EpicPandaForce works well. I tried this way to optimize my app performance and I find the following is a bit faster. Another option for people who prefer speed:

    RealmResults childList = realm.where(Tag.class).equalTo("parentID", id).findAll();
    Tag[] childs = new Tag[childList.size()];
    childList.toArray(childs);
    return Arrays.asList(childs);
    

提交回复
热议问题