realm-java

Realm String greaterThan

别说谁变了你拦得住时间么 提交于 2019-12-01 07:31:11
问题 Is there any way to find all (or just the next) RealmObject s with Strings lexicographically greater than the target? Something like MyEntry next = realm.where(MyEntry.class) .greaterThan("name", current) .findAllSorted("name") .first(); which did not work, because greaterThan is not implemented for String s. 回答1: As a non-db-workaround, you can use List<MyEntry> l = realm.where(MyEntry.class) .findAllSorted("name"); int pos = l.indexOf(entryWithName); MyEntry next = l.get((pos+1)%l.size());