35
4: Using the address book
Change contact information.
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
Contact
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,
"[email protected]");}
3. Create code to manage a
FieldFullException
, which occurs if you invoke an
add
method, such as
addString()
, for a field that already has a value.
Save a contact.
1.
To determine if any contact fields have changed since the contact was last saved,
invoke
isModified()
.
2. Invoke
commit()
.
if(contact.isModified()) {
contact.commit();
}
Task
Steps
Содержание JAVA DEVELOPMENT ENVIRONMENT - - DEVICE APPLICATIONS INTEGRATION - DEVELOPMENT GUIDE
Страница 1: ...BlackBerry Java Development Environment Version 4 6 0 BlackBerry Device Applications Integration Guide...
Страница 4: ......
Страница 7: ......
Страница 10: ...10 BlackBerry Device Applications Integration Guide...
Страница 12: ...12 BlackBerry Device Applications Integration Guide...
Страница 50: ...50 BlackBerry Device Applications Integration Guide...
Страница 56: ...56 BlackBerry Device Applications Integration Guide...
Страница 65: ......
Страница 66: ...2008 Research In Motion Limited Published in Canada...