Reputation: 110
the Blackberry app I'm working at requires me to export all app contacts to the BB address book. I'm able to retrieve the ContactList and create a new contact. However, when I call
AddressBookArguments entry =
new AddressBookArguments(AddressBookArguments.ARG_NEW, contact);
Invoke.invokeApplication(Invoke.APP_TYPE_ADDRESSBOOK, entry);
I'll have the new contact page of the address book poped up and have to manually press the save button. I can't let the user do this for all the contacts.
So my question is, is there a way to auto-save these newly created contacts?
Upvotes: 1
Views: 1440
Reputation: 2279
You can certainly create new contacts programmatically.
Here is some sample code that creates a new contact with a company name and an email address. You can extend this with other fields, such as name, phone number, etc.
ContactList contactList = (ContactList)PIM.getInstance().openPIMList(
PIM.CONTACT_LIST, PIM.WRITE_ONLY);
Contact newContact = contactList.createContact();
newContact.addString(Contact.ORG, Contact.STRING, "ACME Corporation");
if ( contactList.isSupportedField(Contact.EMAIL) )
{
newContact.addString(Contact.EMAIL, Contact.STRING, "[email protected]");
}
newContact.commit();
Upvotes: 6