Create a custom field for linked contacts

You can create a custom field that appears in the contacts application on the BlackBerry® device when a user selects a contact that is linked with a contact in your application.
  1. Import the required classes and interfaces.
    import net.rim.blackberry.api.pdap.contactlinking.*;
    import net.rim.device.api.ui.*;
    import net.rim.device.api.ui.component.*;
  2. Create a class that implements the AddressBookFieldFactory interface.
    public final class SampleAddressBookFieldFactory implements AddressBookFieldFactory
        private String _applicationName;
        public SampleAddressBookFieldFactory(String appName)
            _applicationName = appName;
  3. In the class you created in the previous step, implement AddressBookFieldFactory.createAddressBookField(), which defines the field that you want to add to the contacts application.
    public Field createAddressBookField(final String contactID)
        LinkableContact user = ContactListScreen.getUserForID(contactID);
        if(user == null)
            return null;
        return new BasicEditField(_applicationName + ": ", 
            Field.USE_ALL_WIDTH | Field.READONLY);
  4. Create a variable to store the unique ID of your application.
    public static final long APPLICATION_ID = 0x819417e94b6ca3b7L; 
  5. Instantiate the AddressBookFieldFactory and register it with your application.
    AddressBookFieldFactory factory = new SampleAddressBookFieldFactory("Sample App");
    LinkedContactUtilities.registerAddressBookFieldFactory(factory, APPLICATION_ID);
When a user selects a contact in the contacts application that is linked with a contact in your application, the field that you defined in step 3 appears on the screen of the BlackBerry device.

Code sample: Creating a custom field for linked contacts

To see an example of creating a custom field, see the SampleAddressBookFieldFactory class and the ContactLinkingDemo class in the sample application for contact linking. To download the sample application, visit

Next topic: Task list

Was this information helpful? Send us your comments.