Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Revision as of 06:36, 26 July 2013 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Listing PIM databases using JSR-75

From Wiki
Jump to: navigation, search


Version Hint

Windows Phone: [[Category:Windows Phone]]
[[Category:Windows Phone 7.5]]
[[Category:Windows Phone 8]]

Nokia Asha: [[Category:Nokia Asha]]
[[Category:Nokia Asha Platform 1.0]]

Series 40: [[Category:Series 40]]
[[Category:Series 40 1st Edition]] [[Category:Series 40 2nd Edition]]
[[Category:Series 40 3rd Edition (initial release)]] [[Category:Series 40 3rd Edition FP1]] [[Category:Series 40 3rd Edition FP2]]
[[Category:Series 40 5th Edition (initial release)]] [[Category:Series 40 5th Edition FP1]]
[[Category:Series 40 6th Edition (initial release)]] [[Category:Series 40 6th Edition FP1]] [[Category:Series 40 Developer Platform 1.0]] [[Category:Series 40 Developer Platform 1.1]] [[Category:Series 40 Developer Platform 2.0]]

Symbian: [[Category:Symbian]]
[[Category:S60 1st Edition]] [[Category:S60 2nd Edition (initial release)]] [[Category:S60 2nd Edition FP1]] [[Category:S60 2nd Edition FP2]] [[Category:S60 2nd Edition FP3]]
[[Category:S60 3rd Edition (initial release)]] [[Category:S60 3rd Edition FP1]] [[Category:S60 3rd Edition FP2]]
[[Category:S60 5th Edition]]
[[Category:Symbian^3]] [[Category:Symbian Anna]] [[Category:Nokia Belle]]


The Personal Information Manager (PIM) API for Java ME (JSR-75) allows mobile Java applications to read/write to/from the locally stored personal information databases. There are three categories of PIM databases: contacts, calendar, and to-do. This code snippet demonstrates how to list PIM databases (also called PIM lists) that exist on the device.

Note: Don't be surprised if the MIDlet asks several times for permission to read user data. This is due to the javax.microedition.pim.PIM.listPIMLists() method call and normal behavior for untrusted MIDlets.

Source file:

import javax.microedition.lcdui.Display;
import javax.microedition.midlet.MIDlet;
public class PIMMIDlet extends MIDlet {
private PIMDbForm pimDatabases;
* Constructor. Constructs the object and initializes displayables.

public PIMMIDlet() {
pimDatabases = new PIMDbForm(this);
* From MIDlet.
* Called when the MIDlet is started.

public void startApp() {
* From MIDlet.
* Called to signal the MIDlet to enter the Paused state.

public void pauseApp() {
// No implementation required
* From MIDlet.
* Called to signal the MIDlet to terminate.
* @param unconditional whether the MIDlet has to be unconditionally
* terminated

public void destroyApp(boolean unconditional) {
// No implementation required

Source file:

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.StringItem;
import javax.microedition.pim.PIM;
* A list of PIM databases.

public class PIMDbForm extends Form implements CommandListener {
private Command exitCommand;
private PIMMIDlet parent;
private int itemCounter = 0; // How many items are listed
public PIMDbForm(PIMMIDlet parent) {
super("PIM databases");
this.parent = parent;
exitCommand = new Command("Exit", Command.EXIT, 0);
// Retrieve the PIM instance
PIM pim = PIM.getInstance();
// Add each type of PIM lists (PIM databases) to the form
addList(PIM.CONTACT_LIST, pim);
addList(PIM.EVENT_LIST, pim);
addList(PIM.TODO_LIST, pim);
public void commandAction(Command command, Displayable displayable) {
if (command == exitCommand) {
// Exit the MIDlet
* Adds the names of specific types of PIM lists (databases) to the form.
* @param listType the type of list
* @param pim PIM instance from which the databases are queried

private void addList(int listType, PIM pim) {
String[] list = pim.listPIMLists(listType);
for (int i = 0; i < list.length; i++) {
StringItem item = new StringItem("Database " + itemCounter, list[i]);


The MIDlet displays all PIM databases that exist on the device on a form.

This page was last modified on 26 July 2013, at 06:36.
59 page views in the last 30 days.