title: How to remove duplicate contacts in vcf file
body: <p>Hi guys i have this code which i use to get contacts from the phone and store them in vcf format,the code works properly for contacts that have only one number but i keep getting duplicates for contacts with multiple numbers i.e contacts that have home number,work number e.t.c...any help will be appreciated.....this is my code below</p>
  
  <pre><code>import java.io.File;
  import java.io.FileInputStream;
  import java.io.FileOutputStream;
  import java.util.ArrayList;
  import android.app.Activity;
  import android.content.Context;
  import android.content.res.AssetFileDescriptor;
  import android.database.Cursor;
  import android.net.Uri;
  import android.os.Bundle;
  import android.os.Environment;
  import android.provider.ContactsContract;
  import android.util.Log;
  
  
      public class Show_contacts extends Activity {
          Cursor cursor;
          ArrayList&lt;String&gt; vCard;
          String vfile;
          static Context mContext;
  
          /** Called when the activity is first created. */
          @Override
              public void onCreate(Bundle savedInstanceState) {
                  super.onCreate(savedInstanceState);
                  setContentView(R.layout.activity_main);
                  mContext = Show_contacts.this;
                  getVCF();
              }
  
              public static void getVCF() {
                  final String vfile = "Contacts.vcf";
                  Cursor phones = mContext.getContentResolver().query(
                  ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, null, null, null);
                  phones.moveToFirst();
                  for (int i = 0; i &lt; phones.getCount(); i++) {
                      String lookupKey = phones.getString(phones.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY));
                      Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_VCARD_URI, lookupKey);
                      AssetFileDescriptor fd;
                      try {
                          fd = mContext.getContentResolver().openAssetFileDescriptor(uri, "r");
                          FileInputStream fis = fd.createInputStream();
                          byte[] buf = new byte[(int) fd.getDeclaredLength()];
                          fis.read(buf);
                          String VCard = new String(buf);
                          String path = Environment.getExternalStorageDirectory().toString() + File.separator + vfile;
                          FileOutputStream mFileOutputStream = new FileOutputStream(path, true);
                          mFileOutputStream.write(VCard.toString().getBytes());
                          phones.moveToNext();
                          Log.d("Vcard", VCard);
                          mFileOutputStream.close();
                      } catch (Exception e1) {
                          // TODO Auto-generated catch block
                          e1.printStackTrace();
                      }
                  }
              }
          }
  </code></pre>