tags:

views:

518

answers:

2

The Android 2.0 SDK has a import/export option to export or import contacts in VCard format.

Is there any API to achieve this functionality.

+2  A: 

Try such code for export to VCard:

Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_VCARD_URI, lookupKey);
AssetFileDescriptor fd = contentResolver.openAssetFileDescriptor(uri, "r");
FileInputStream fis = fd.createInputStream();
byte[] buf = new byte[(int)fd.getDeclaredLength()];
if (0 < fis.read(buf))
{
   String vCard = new String(buf);
}
Ilya Izhovkin
A: 

And how to create a new contact using this vCard in Android?

Cheers, Prateek

Prateek Jain