Import Contacts from .vcf file in Android 2.1

Posted by Prateek Jain on Stack Overflow See other posts from Stack Overflow or by Prateek Jain
Published on 2010-11-10T11:55:08Z Indexed on 2011/01/17 3:53 UTC
Read the original article Hit count: 326

Filed under:

Hi All,

I am able to retrieve all contacts from android in .vcf file using following code.

    ContentResolver cr = getContentResolver();
    Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI,null, null, null, null);
String lookupKey = cur.getString(cur.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY));
                        Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_VCARD_URI, lookupKey);
                        System.out.println("The value is " + cr.getType(uri));
                        AssetFileDescriptor fd = this.getContentResolver().openAssetFileDescriptor(uri, "r");
                        FileInputStream fis = fd.createInputStream();

I don't know how to use this .vcf file to import all these contacts using code. The .vcf file contains all the details of all contacts including photos etc.

Cheers, Prateek

© Stack Overflow or respective owner

Related posts about android