Blackberry JAVA DEVELOPMENT ENVIRONMENT - - DEVICE APPLICATIONS INTEGRATION - DEVELOPMENT GUIDE Integration Manual page 35

Blackberry device applications integration guide
Table of Contents

Advertisement

Task
Change contact information.
Save a contact.
Steps
1. To change the name and address fields, invoke the appropriate set method to replace
an existing value with a new value.
2. Perform one of the following actions:
• To change the fields that support a single value, retrieve the array and then change
one or more indexes in the array before adding the array back to the
object.
if (contact.countValues(Contact.NAME) > 0) {
String[] newname = contact.getStringArray(Contact.NAME, 0);
}
// Change the prefix to Dr. and add the suffix, Jr.
newname[Contact.NAME_PREFIX] = "Dr.";
newname[Contact.NAME_SUFFIX] = "Jr.";
contact.setStringArray(Contact.NAME, 0, Contact.ATTR_NONE,
newname);
• To change the contacts fields that support multiple values, before adding another
value, verify that the number of values does not exceed the maximum number of
values. For example:
if (contact.countValues(Contact.EMAIL) <
contactList.maxValues(Contact.EMAIL)) {
contact.addString(Contact.EMAIL, Contact.ATTR_NONE,
"aisha.wahl@blackberry.com");}
FieldFullException
3. Create code to manage a
addString()
method, such as
1. To determine if any contact fields have changed since the contact was last saved,
isModified()
invoke
.
commit()
2. Invoke
.
if(contact.isModified()) {
contact.commit();
}
4: Using the address book
, which occurs if you invoke an
, for a field that already has a value.
Contact
add
35

Advertisement

Table of Contents
loading

This manual is also suitable for:

Java development environment 4.6.0

Table of Contents