This article applies to the BlackBerry® Java® Development Environment (JDE) 4.1 and later.
A custom or new category can be added to the following PIMItem interfaces during creation:
- Contact
- ToDo
- Memo (as of BlackBerry JDE 4.2)
For these interfaces, there are two default categories available: Personal and Business.
To add a custom category, the category must be first added to the PIMList, and only then can be added to the PIMItem itself.
For example, using the javax.microedition.pim.ContactList and javax.microedition.pim.Contact interfaces:
ContactList contactList = (ContactList)PIM.getInstance().openPIMList(PIM.CONTACT_LIST, PIM.WRITE_ONLY);
Contact contact = contactList.createContact();
// Adds the category inputted to the ContactList.
contactList.addCategory("MyCategory");
…
// Adds the same category inputted to the contact.
contact.addToCategory("MyCategory");
If the category is not added to the PIMList prior to attempting to add it to the PIMItem, a PIMException will be thrown.