tags:

views:

121

answers:

1

Hi

I m trying to convert the contacts on emulator to VCard format using the code below

AssetFileDescriptor afd =openAssetFileDescriptor(Contacts.CONTENT_VCARD_URI ,"r")

The stack Trace says java.io.FileNotFoundException No file at content://com.android.contacts/contacts/as_vcard

Do we need to attach a file to the URI ? Is there some other way to convert Contacts to Vcard in Android?

A: 

You have to iterate through the contact db and call openAssetFileDescriptor() on each one individually. The important part is that you have to use the lookup key for each contact and append it to the CONTENT_VCARD_URI using the URI.withAppendedPath() method.