I use the following code to read contacts and create a vcard file.
String lookupKey = cur.getString(cur.getColumnIndex(Contacts.LOOKUP_KEY));
Uri uri=Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_VCARD_URI, lookupKey);
try {
fd = cr.openAssetFileDescriptor(uri, "r");
} catch (FileNotFoundException e) {
e.printStackTrace();
}
try {
fis = fd.createInputStream();
} catch (IOException e) {
e.printStackTrace();
}
byte[] buf = new byte[(int)fd.getDeclaredLength()];
try {
if (0 < fis.read(buf))
{
vCard = new String(buf);
writer.write(vCard);
writer.write("\n");
}
} catch (IOException e) {
e.printStackTrace();
}
But when viewing the contact list, I get an error message:
ERROR / MemoryFile (284): Called MemoryFile.finalize () ashmem is still open.
And my generated .vcf file doesnβt have some contacts, nor does it end up properly.
Can someone please tell me what is wrong with my code.
Anilv source
share