问题
I am making Vcard using this code , now I want In my vcard don't insert code of image , all other things will added in vcard , how I do it .... I'm using this
String VCard = "";
Cursor phones = getContentResolver().query(android.provider.ContactsContract.Contacts.CONTENT_URI , null,null, null, null);
phones.moveToFirst();
pDialog.setMax(phones.getCount());
for(int i =0;i<phones.getCount();i++)
{
String lookupKey = phones.getString(phones.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);
VCard += new String(buf);
String y =String.valueOf(i);
publishProgress(y);
phones.moveToNext();
Log.d("Vcard", VCard);
}
catch (Exception e1)
{
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
try {
FileOutputStream mFileOutputStream = new FileOutputStream(file, false);
mFileOutputStream.write(VCard.toString().getBytes());
mFileOutputStream.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
回答1:
String lookupKey = phones.getString(phones
.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY));
Uri vcardUri = ContactsContract.Contacts.CONTENT_VCARD_URI
.buildUpon()
.appendQueryParameter("nophoto", String.valueOf(true))
.build();
Uri uri = Uri.withAppendedPath(vcardUri, lookupKey);
I have modify it again,use in for loop
来源:https://stackoverflow.com/questions/15333022/donot-insert-image-source-code-when-making-vcard-in-api-level-8