+ e.toString());
return null;
}
// Create a new BlackBerryContact
BlackBerryContact contact =
(BlackBerryContact) contacts.createContact();
// Set the mobile phone number for the new BlackBerryContact
final String mobileNumber =
linkableContact.getString(LinkableContact.MOBILE_PHONE);
if (mobileNumber != null) {
contact.addString(Contact.TEL, Contact.ATTR_MOBILE, mobileNumber);
}
// Set the email address for the new BlackBerryContact
final String emailAddress =
linkableContact.getString(LinkableContact.EMAIL);
if (emailAddress != null) {
contact.addString(Contact.EMAIL, Contact.ATTR_PREFERRED,
linkableContact.getString(LinkableContact.EMAIL));
}
// Set the name for the new BlackBerryContact
final String[] names =
StringUtilities.stringToWords(linkableContact
.getString(LinkableContact.NAME));
final String[] nameArray =
new String[contacts.stringArraySize(Contact.NAME)];
nameArray[Contact.NAME_FAMILY] = names[1];
nameArray[Contact.NAME_GIVEN] = names[0];
contact.addStringArray(Contact.NAME, PIMItem.ATTR_NONE, nameArray);
// Invoke the Adress Book application
final AddressBookArguments abArg =
new AddressBookArguments(AddressBookArguments.ARG_NEW, contact);
Invoke.invokeApplication(Invoke.APP_TYPE_ADDRESSBOOK, abArg);
try {
// Commit changes to the contact model
contact.commit();
// Link the linkable contact with the new BlackBerry contact
contact =
LinkedContactUtilities
.linkContact(contact, linkableContact);