how to remove duplicate contacts from arraylist

前端 未结 5 1533
谎友^
谎友^ 2021-01-16 21:13

I have created an app in which I am getting the contacts from a device. But I want to remove the duplicate contacts from the results.

How could I do it?

5条回答
  •  太阳男子
    2021-01-16 22:02

    Add the following checking in the place of list.add(new ProfileBean(name, phoneNumber)); before adding into list:

    int flag = 0
    if(list.size() == 0){
    list.add(new ProfileBean(name, phoneNumber));
    }
        for(int i=0;i

    }

        }
    if(flag == 1){
    list.add(new ProfileBean(name, phoneNumber));
    }
    

提交回复
热议问题