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
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<User> 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.
You can find more information about this method here in the official documentation. https://realm.io/docs/java/latest/api/io/realm/Realm.html#distinct-java.lang.Class-java.lang.String-][1]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With