Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Access and Obtain Service Books on a device

by Retired on ‎02-16-2010 09:50 AM (5,842 Views)


This article applies to the following:

  • BlackBerry® wireless devices based on Java™
  • BlackBerry Java Development Environment (JDE) 4.0


The BlackBerry JDE 4.0 has a package, net.rim.device.api.servicebook, that allows the retrieval of service book information on a BlackBerry device.

The example below uses both the ServiceBook and ServiceRecord classes to obtain the APN of the WAP Browser service book:

import net.rim.device.api.system.*;
import net.rim.device.api.servicebook.*;

public class ServiceBookExample extends Application {

    ServiceRecord[] _sRecordsArray; //Creates a ServiceRecord array.
    ServiceBook _servicebook; //Creates a ServiceBook variable.
    String cidValue, sbName, sbAPN;

    public static void main(String[] args)
        // Create a new instance of the application and
        // start the event thread.
        ServiceBookExample app = new ServiceBookExample();

    public ServiceBookExample() {

        // Returns a reference to the service book from the factory.
        _servicebook = ServiceBook.getSB();

        // Returns an array of all registered service records.
        _sRecordsArray = _servicebook.getRecords();

        // Loops through the service record array
        // and obtains specific information relating
        // to each item and prints it to the debugging output.
        for(int i = 0; i < _sRecordsArray.length; i++) {
            // Obtains the Service Book CID
            cidValue = _sRecordsArray[i].getCid();

            // Obtains the Name of the Service Book
            sbName = _sRecordsArray[i].getName();

              && sbName.startsWith("WAP Browser")) {
                // Obtains the Service Book's APN
                // (Associated Access Point Name)
                String sbAPN = _sRecordsArray[i].getAPN();


Additional Information

For a complete listing of available methods, please see the API reference included within the BlackBerry JDE 4.0. Additional information can be found in Chapter 10 of the BlackBerry Application Developer Guide Volume 2.

Users Online
Currently online: 31 members 1,888 guests
Please welcome our newest community members: