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);
AssetFileDescriptor fd = this.getContentResolver().openAssetFileDescriptor(uri, "r");
FileInputStream fis = fd.createInputStream();
Above code can be used to export the contacts in vcf format. Read all the contacts from the fileInputStream object "fis".
Also, don't forget to add the permissions in the manifest file -
<uses-permission android:name="android.permission.READ_CONTACTS" />
Can anyone help with importing the same .vcf file to the Android using some API?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…