I have got a Realm object class, and storing lots of data in there, imagine that I have a String uid; field. I want to get uid names, but on same uid names just only one time,
For example
uid
AA
AA
BB
CC
DD
BB
BB
I want to get just
AA,
BB,
CC,
DD.
Only one time.
I looked over realm documentation but couldn't find anything.
Thanks for answers.
解決方案
UPDATED :
You can use distinct() to get distinct entries for an object class.
// Returns the set of users that all have a different name
RealmResults users = realm.where(User.class).distinct("name");
Note:
.distinct will only work on fields that are indexed (@Index or @PrimaryKey).
It doesn't work with child object property.