Import / export format to VCard format programmatically using API level 5 for Android OS 2.0

The Android 2.0 SDK has an import / export option for exporting or importing contacts in VCard format.

Is there any API to achieve this functionality.

+3
source share
1 answer

Try using this code to 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);
}
+3
source

Source: https://habr.com/ru/post/1722671/


All Articles