Hi dom,
You need to use the "VCard.getExtendedType()" method to retrieve the custom labels. This method is used to retrieve non-standard and extended properties (e.g. properties that begin with "X-"):
VCard vcard = Ezvcard.parse(vCardFile).first();
List<RawType> customLabels = vcard.getExtendedType("X-ABLabel");
String customLabel = customLabels.get(0).getValue();
If there are multiple emails in the vCard, it looks like you will need more extensive logic in order to match each email address with its corresponding label. The code below
stores each email/label combination inside of a String array. If the email address doesn't have a custom label, then a null value will be associated with it.
public List<String[]> groupEmailsWithTheirLabels(VCard vcard){
List<String[]> emailsAndLabels = new ArrayList<String[]>();
List<EmailType> emails = vcard.getEmails();
List<RawType> customLabels = vcard.getExtendedType("X-ABLabel");
for (EmailType email : emails){
String emailValue = email.getValue();
String customLabelValue = null;
String group = email.getGroup();
if (group != null){
for (RawType customLabel : customLabels){
if (group.equals(customLabel.getGroup())){
customLabelValue = customLabel.getValue();
break;
}
}
}
emailsAndLabels.add(new String[]{emailValue, customLabelValue});
}
return emailsAndLabels;
}
Regards,
Mike
> --
> You received this message because you are subscribed to the Google Groups "ez-vcard-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
ez-vcard-discu...@googlegroups.com.
> To post to this group, send email to
ez-vcard...@googlegroups.com.
> To view this discussion on the web visit
https://groups.google.com/d/msg/ez-vcard-discuss/-/3JttpOgEMt0J.
> For more options, visit
https://groups.google.com/groups/opt_out.
>
>