领域java不同的RealmQuery 类项目{ int型; 字符串值; } RealmResults结果=realm.where(Item.class) .equalTo(“类型”,类型) .findAll();

领域java不同的RealmQuery 类项目{ int型; 字符串值; } RealmResults结果=realm.where(Item.class) .equalTo(“类型”,类型) .findAll();,java,android,distinct,realm,Java,Android,Distinct,Realm,领域上有许多重复的值。 我想得到唯一的价值结果 class Item { int type; String value; } RealmResults<Item> result = realm.where(Item.class) .equalTo("type", type) .findAll(); RealmResults result=realm.where(Item.class) .equalTo(“类型”,类型) .独特(“价

领域上有许多重复的值。 我想得到唯一的价值结果

class Item {
    int type;
    String value;
}

RealmResults<Item> result = realm.where(Item.class)
        .equalTo("type", type)
        .findAll();
RealmResults result=realm.where(Item.class)
.equalTo(“类型”,类型)
.独特(“价值”)
.findAll();
像这样。
有什么解决办法吗?

没有。你的解决办法是唯一正确的。没有。你的解决方案是唯一正确的。
RealmResults<Item> result = realm.where(Item.class)
        .equalTo("type", type)
        .distinct("value")
        .findAll();