* was not successful
*/
private static BlackBerryContact createContactFor(
final LinkableContact linkableContact) {
// Obtain list of contacts
BlackBerryContactList contacts;
try {
contacts =
(BlackBerryContactList) PIM.getInstance().openPIMList(
PIM.CONTACT_LIST, PIM.READ_WRITE);
} catch (final PIMException e) {
ContactLinkingDemo
.errorDialog("Could not open contacts list. PIM#openPIMList() threw "
+ 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