try {
verifyPIMSupport();
PIM pimInst = PIM.getInstance();
contList = (ContactList) pimInst.openPIMList(PIM.CONTACT_LIST, PIM.READ_ONLY);
enumContacts = contList.items();
mainList = new List(":.:PHONE BOOK:.:", List.IMPLICIT);
addCommand = new Command("ADD CONTACTS", Command.OK, 0);
listCommand = new Command("LIST CONTACTS", Command.OK, 0);
exitCommand = new Command("EXIT", Command.EXIT, 0);
deleteCommand = new Command("DELETE ALL", Command.OK, 0);
while (enumContacts.hasMoreElements()) {
Contact tCont = (Contact) enumContacts.nextElement();
String[] name_struct = tCont.getStringArray(Contact.NAME, 0);
String firstname = name_struct[Contact.NAME_GIVEN];
String lastname = name_struct[Contact.NAME_FAMILY];
//String email = tCont.getString(Contact.EMAIL, 0);
// String number = tCont.getString(Contact.TEL, 0);
//String org = tCont.getString(Contact.ORG, 0);
String person = "First Name:" + firstname+ "\n" + "Last Name:"
+ lastname ;
//String person = "First Name:" + firstname + "\n" + "Last Name:"
//+ lastname + "\n" + "N0:" + number + "\n" + "Email:" + email + "\n" + "Org:" + org;
mainList.setFitPolicy(1);
mainList.append(person, null);
}
mainList.addCommand(addCommand);
mainList.addCommand(listCommand);
mainList.addCommand(exitCommand);
mainList.addCommand(deleteCommand);
mainList.setCommandListener(this);
display = Display.getDisplay(this);