次のコードを使用して、1人の連絡先のvcfファイルを作成しています。私が望むのは、特定の連絡先をクリックすると、その連絡先のvcfファイルが作成されるということです。選択した連絡先の.vcfファイルを作成する方法
String vfile = "test1.vcf";
cursor = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, null, null, null);
cursor.moveToFirst();
String lookupKey = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY));
Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_VCARD_URI, lookupKey);
AssetFileDescriptor fd;
try {
fd = getContentResolver().openAssetFileDescriptor(uri, "r");
FileInputStream fis = fd.createInputStream();
byte[] buf = new byte[(int) fd.getDeclaredLength()];
fis.read(buf);
String VCard = new String(buf);
String path = Environment.getExternalStorageDirectory().toString() + File.separator + vfile;
FileOutputStream out = new FileOutputStream(path);
out.write(VCard.toString().getBytes());
Log.d("Vcard", VCard);
} catch (Exception e1)
{
// TODO Auto-generated catch block
e1.printStackTrace();
}
任意の助けをいただければ幸い: は、ここで私が使用していたコードです。
が私を助けて "インテリジェント灰" http://stackoverflow.com/questions/13198933/cant-find-vcf-file-on-sdcard-android-emulator/13199144#comment17969669_13199144 おかげで進歩 –