Hi,
I am not sure about this but I think the contact with no name may return an empty String when you call
item.getString(Contact.FORMATTED_NAME, 0).
You may try this:
Code:
ContactList list = (ContactList) pim.openPIMList(PIM.CONTACT_LIST, PIM.READ_ONLY, listNameToOpen);
Enumeration enumeration = list.items();
while (enumeration.hasMoreElements())
{
Contact contact = (Contact) enumeration.nextElement();
String contactName = "";
if (list.isSupportedField(Contact.FORMATTED_NAME))
{
String formattedName = contact.getString(Contact.FORMATTED_NAME, 0);
if (formattedName != null && !formattedName.equals(""))
{
contactName = formattedName;
}
else
{
contactName = "(Unnamed)";
}
}
else
{
// in case list is not support field Contact.FORMATTED_NAME,
// you may get contactName from field Contact.NAME
// or contactName = "(Unnamed)";
}
contactNameVector.addElement(contactName);
}
list.close();