Wednesday, September 19, 2012

How to import phone contacts in Nokia Emulator for use with Java ME

Got stuck today while trying to load phone contacts in the Nokia emulator while testing out some new apps I'm working on.

For JavaME SDK 3.0, you can simply save various contacts in *.vcf format in the directory /runtimes/cldc-hi-javafx/appdb/PIM/contacts/Contacts and have it work as expected when loading contacts with PIM, but in the case of Nokia SDKs, it's a different story entirely. I tried writing to PIM, then load the contacts thereafter, but on each relaunch of the app, the contacts previously written have to be rewritten before they can be used again besides the nagging permission prompts for each write.

After taking some much needed break from testing and debugging, I eventually found the way out. To make contacts persistent in the Nokia Emulator, simply start the emulator, and wait for it to be fully loaded; then go to the menu File -> Open, select Save after loading the contact and then load the *.vcf file(s). Once you've done that, you can proceed to loading the previously saved contact(s) with JSR-75.

Here's a sample VCARD you can test with or edit to taste:

begin:vcard
fn:David Baldacci
n:Baldacci; David;; 
TEL;HOME;VOICE:123-456-7890
TEL;CELL;VOICE:987-654-3210
URL;HOME:http://davidbaldacci.net
EMAIL;INTERNET:author@davidbaldacci.net
version:2.1
end:vcard