Newsletter:

(Tutorial) J2ME - Personal Information Management

Tutorial : J2ME - Personal Information Management

Personal Information Management (PIM) API for Java Micro Edition is included in J2ME profiles as an optional package. It is developed as part of JSR 75 and there is no dependency of these PIM API upon any other APIs produced in JSR 75.

This API resides in a new J2ME package, javax.microedition.pim.

PIM APIs are very useful in following ways:

PIM API can be used to access the address book residing in the mobile device. You must be knowing that nearly all the mobile devices these days supports address book where you can store your contact. So if you want to access that address book, PIM APIs provides you support for that.

Similarly, you can access the TODO list and calendar using PIM API. One can say that you can access native PIM database using PIM API. This is a very useful support since you cannot access the files residing in the PIM folder of mobile device.

Security issues are also addressed in PIM API and only authorized Java applications can access the entries contained in the PIM lists.

Considering the limited J2ME CLDC space, PIM API implementation is memory and performance efficient.

If you are interested in synchronizing your address book, then import and export options are of great interest for you. Good thing is that import and export of address book entries in a vCard format (specified by the Internet Mail Consortium) is also provided by the PIM API.

Synchronization issues
You if are interested in playing with the PIM database entries, you should know that PIM API does not provide locking operations. On the other hand, PIM implementations ensure that all PIM records are atomic, synchronous, and serialized – which means that no corruption occurs with multiple accesses.

Tricky situation occurs when you write a multithreaded application and multiple threads try to access the PIM entries. In this situation, you as a developer have to deal with the situation by coordinating the access of threads to your PIM records. In other case, unintended consequences may result.

For example:
Categories in a particular contact list may be modified by a native application threads concurrently – which would mean that the contents will be over written by the thread the committed last.

It is right to say that PIM API is not required to handle multitasking environments and concurrent access to PIM data.

Creating contacts
You might be thinking about creating contacts in the test environment. You can create contacts in Ms Outlook and then copy those to the required directory.

Contact file have extension vcf. You should use SUN wireless toolkit for creating and testing mobile applications. It provides emulator as well. Place the contact files (vcf files) in the following directory:

..\j2mewtk\2.5.2\appdb\DefaultColorPhone\pim\conta cts\Contacts

Now you can access these contacts from your application.

There is another way to create contacts. You can write your own MIDlet which can create contacts. SUN wireless toolkit comes with a sample application for creating contacts which you can also use to create contacts. It is called PDAPDemo (JSR 75 FileConnection & PIM demonstration). If you use it, the created contacts will be places by default in the required directory...

[Read More..]

Courtesy:- Java-forums.org