I have done R&D for limit in query with no success. There is one way with which to paginate data in Realm
with sub list but no success with that. It shows d
As @EpicPandaForce said, you can use lessThan()
and greaterThan()
to set the limit, but realm have between()
method, check: https://realm.io/docs/java/latest/#chaining-queries
Example :
Just get items with limit 50 :
static int LIMIT = 50;
final RealmResults- resultsFilter = realm.where(Item.class)
.between("id", 0, LIMIT)
.findAllSorted("id", Sort.ASCENDING);
Or when I want to get last 10 items:
static int LIMIT = 10;
final RealmResults- resultsAll = realm.where(Item.class).findAll();
final RealmResults
- resultsFilter = realm.where(Item.class)
.between("id", resultsAll.size() - LIMIT, resultsAll.size())
.findAllSorted("id", Sort.DESCENDING);