Nokia N96 do not support Contact.FORMATTED_NAME if you are trying to read phones Contact List.
Workaround for this:
1. Use Contact.NAME insted of Contact.FORMATTED_NAME.
2. This family uses Contact.NAME but is stored as a string array. So you must use the getStringArray method rather than the getString.
3. Use getStringArray method when you are using Contact.FORMATTED_NAME and use getString when you are using Contact.NAME.
Demo Code:
import java.util.Enumeration;
import java.util.Vector;
import javax.microedition.pim.Contact;
import javax.microedition.pim.ContactList;
import javax.microedition.pim.PIM;
public class Pim {
static ContactList contactList;
public static Vector getContact() {
Vector vector = new Vector();
try {
contactList = (ContactList) pim.openPIMList(PIM.CONTACT_LIST,
PIM.READ_WRITE);
Enumeration contacts = contactList.items();
while (contacts.hasMoreElements()) {
Contact c = (Contact) contacts.nextElement();
String home = c.getString(Contact.TEL, 0);
//Note: If You are using Contact.NAME then use getStringArray
String[] name = c.getStringArray(Contact.NAME, 0);
////Note: If You are using Contact.FORMATTED_NAME then use getStringArray
//String name = c.getString(Contact.FORMATTED_NAME, 0);
vector.addElement(home + "-" + name[0]);
}
} catch (Exception e) {
System.out.println("Error is =======" + e);
}
return vector;
}
}
