Troubleshooting guide

172
BlackBerry Java Development Environment Development Guide
Add contact information. 1. Invoke one of the following methods:
addString()
addStringArray()
addDate()
addInt()
addBoolean()
addBinary()
2. Before you set or retrieve a field, to verify that the item supports the field, invoke
ContactList.isSupportedField(int).
3. To let fields store multiple values, use field attributes. For example, the TEL field
supports the ATTR_HOME, ATTR_WORK, ATTR_MOBILE, and ATTR_FAX attributes to
store numbers for work, home, mobile, and fax numbers.
4. To determine how many values a field supports, invoke PIMList.maxValues(int
field)
.
5. To verify that a field supports a particular attribute, invoke
isSupportedAttribute(int, int).
// Create string array for name.
try {ContactList contactList =
(ContactList)PIM.getInstance().openPIMList(PIM.CONTACT_LIST,
PIM.WRITE_ONLY);}
catch (PIMException e) {}
Contact contact = contactList.createContact();String[] name = new
String[5];
// 5 name elements
try {name[Contact.NAME_PREFIX] = "Mr.";name[Contact.NAME_FAMILY] =
"McPherson";name[Contact.NAME_GIVEN] = "Scott";}
catch (IllegalArgumentException iae)
{// handle exception}
// Add name.
if(contactList.isSupportedField(Contact.NAME))
{contact.addStringArray(Contact.NAME, Contact.ATTR_NONE, name);
}
// Create string array for address.
String[] address = new String[7];
// 7 address elements
try {address[Contact.ADDR_COUNTRY] = "United
States";address[Contact.ADDR_LOCALITY] = "Los
Angeles";address[Contact.ADDR_POSTALCODE] =
"632300";address[Contact.ADDR_REGION] =
"California";address[Contact.ADDR_STREET] = "323 Main Street";}
catch (IllegalArgumentException iae) {// Handle exception.}
// Add address.contact.addStringArray(Contact.ADDR,
Contact.ATTR_NONE, address);
// Add home telephone number.
if (contactList.isSupportedField(Contact.TEL)
&&contactList.isSupportedAttribute(Contact.TEL,
Contact.ATTR_HOME)) {contact.addString(Contact.TEL,
Contact.ATTR_HOME, "555-1234");}
// Add work telephone number.if
(contactList.isSupportedField(Contact.TEL))
{contact.addString(Contact.TEL, Contact.ATTR_HOME, "555-5555");}
// Add work internet messaging address.
if (contactList.isSupportedField(Contact.EMAIL))
{contact.addString(Contact.EMAIL, Contact.ATTR_WORK,
"aisha.wahl@blackberry.com");}
Task Steps