Retrieve call information by using call logs

Call information on a BlackBerry® device is recorded in the call logs which can be accessed from the messages list. The call logs are stored in call log folders that you can access by using the PhoneLogs.FOLDER_NORMAL_CALLS or PhoneLogs.FOLDER_MISSED_CALLS constants.
  1. Import the required classes.
    import net.rim.blackberry.api.phone.phonelogs.*;
  2. Invoke getInstance() to retrieve an instance of the call log.
    PhoneLogs _logs = PhoneLogs.getInstance();
  3. Invoke numberOfCalls() to retrieve the total number of calls in a specified call log folder (FOLDER_MISSED_CALLS or FOLDER_NORMAL_CALLS).
    int numberOfCalls = _logs.numberOfCalls(PhoneLogs.FOLDER_NORMAL_CALLS);
  4. Invoke PhoneLogs.callAt() to retrieve call information from a call log, passing in the index for the call log, and the call log folder.
    PhoneCallLog phoneLog = (PhoneCallLog)_logs.callAt(0,PhoneLogs.FOLDER_NORMAL_CALLS);
  5. Invoke PhoneCallLog.getType() to retrieve the call type. The possible return values are TYPE_MISSED_CALL_OPENED, TYPE_MISSED_CALL_UNOPENED, TYPE_PLACED_CALL, or TYPE_RECEIVED_CALL.
    int phoneType = phoneLog.getType();

Was this information helpful? Send us your comments.