Unable to share Vcf contact card for Android 11 and above.
Closed this issue · 1 comments
nidhi548 commented
Hi, I am unable to share a contact from native to my android app. please help here.
nidhi548 commented
public static File createVcardFile(VCard vCard) {
File filePath = FileUtils.getFilesFolder(); **// /storage/emulated/0/xyz/xyz files/**
File file = new File(filePath, "ContactCard_" + System.currentTimeMillis() + ".vcf"); **// /storage/emulated/0/xyz/xyz files/ContactCard_1646212512605.vcf**
VCardWriter writer = null;
try {
writer = new VCardWriter(file, VCardVersion.V4_0); **// null**
writer.write(vCard);
} catch (Exception e) {
FileLogUtils.e(TAG, "createVcard(): " + e);
} finally {
if (writer != null) { // null
try {
writer.close();
} catch (IOException e) {
FileLogUtils.e(TAG, "createVcard(): " + e);
}
}
}
return file; **// returns file path**
}
// file path is returned but vcard is empty because writer is null