Create a contact list
You can create contact lists on a BlackBerry® device. Note the following about contact lists that you create:
- Each contact list has a unique ID, which is the value that is returned by createPIMList().
- The contact lists do not have service records and do not support wireless synchronization.
- Applications can register to listen for changes to your contact list by invoking BlackBerryPIMList.addListener().
Code sample
BlackBerryPIM myPIM = (BlackBerryPIM) PIM.getInstance();
try
{
// create a contact list
long listUID = myPIM.createPIMList(PIM.CONTACT_LIST, "test");
// add a contact to the list
BlackBerryContactList contactList =
(BlackBerryContactList) myPIM.openPIMList(PIM.CONTACT_LIST,
PIM.READ_WRITE, listUID);
Contact contact = contactList.createContact();
String[] name = new String[contactList.stringArraySize(Contact.NAME)];
name[Contact.NAME_GIVEN] = "Noha";
name[Contact.NAME_FAMILY] = "Toma";
contact.addStringArray(Contact.NAME, PIMItem.ATTR_NONE, name);
contact.addString(Contact.TEL, Contact.ATTR_HOME, "519-555-0151");
contact.addString(Contact.TEL, Contact.ATTR_WORK, "519-555-0199");
contact.commit();
// close the contact list
contactList.close();
}
catch (PIMException e)
{
System.out.println(e.getMessage());
}
Next topic: Remove a contact list
Previous topic:
Creating and removing contact lists