title: Removing Duplicates from Contacts list
body: <p>I have been working on an android app to show <code>contacts</code> in the list. I am using <code>recyclerview</code> and i am able to show the contacts with name and image in the list.</p>
  
  <p>But my list contains the duplicate of contact numbers. I used the below code to remove the duplicates but it shows </p>
  
  <p><code>9566191161</code>
  <code>+919566191161</code> as two entries. (ie.,) Along with country code, it is showed as a separate entry.</p>
  
  <p>I am using a POJO class and adding it to Adapter as a List.  In Pojo Class, i used the coding to remove duplicates like </p>
  
  <pre><code>  @Override
      public boolean equals(Object obj) {
          // TODO Auto-generated method stubs
          if (obj instanceof ContactVO) {
              ContactVO temp = (ContactVO) obj;
              if (this.getContactNumber() == temp.getContactNumber() &amp;&amp; this.getContactName() == temp.getContactName() &amp;&amp; (this.getContactNumber()).contains(temp.getContactNumber()))
                  return false;
          }
          return true;
      }
  
      @Override
  
      public int hashCode() {
          // TODO Auto-generated method stub
          return (this.getContactNumber().hashCode() + this.getContactName().hashCode());
      }
  }
  </code></pre>
  
  <p>I used as <code>"+91"+this.getContactNumber().contains(temp.getContactNumber())</code> validation in the equals method but it doesn't remove that duplicate.</p>
  
  <p>Can you guys please help me in this error.</p>
  
  <p>My code snippet</p>
  
  <pre><code> Cursor phones = getContext().getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, null, null, null);
          while (phones.moveToNext()) {
              name = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
              phoneNumber = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)).replace(" ", "");
              imageUri = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.PHOTO_URI));
              System.out.println("Name and Phone number = " + name + phoneNumber + imageUri);
  
  
              contactVOList.add(new ContactVO(imageUri, name, phoneNumber));
              System.out.println("List size before removing duplicates =" + contactVOList.size());
  
          }
  
          Set&lt;ContactVO&gt; s = new HashSet&lt;ContactVO&gt;();
          s.addAll(contactVOList);
          contactVOList = new ArrayList&lt;ContactVO&gt;();
          contactVOList.addAll(s);
  
  
          // contactVOList = removeDuplicates(contactVOList);
          System.out.println("List size after removing duplicates =" + contactVOList.size());
          System.out.println("ListSize before sendinf" + contactVOList.size());
          mAdapter = new AllContactsAdapter(getContext(), contactVOList, userId, mobilenumber);
          RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getContext());
          rvContacts.setLayoutManager(mLayoutManager);
          rvContacts.setItemAnimator(new DefaultItemAnimator());
          rvContacts.setAdapter(mAdapter);
  </code></pre>
  
  <p>Happy new year guys !</p>