i am trying to make a program that edits contacts on a Nokia phone using J2ME
but i don't know how to access the contacts help please

Dani AI

Generated

Short expert note for (and thanks to for the forum pointer): the standard J2ME way to read and edit phone contacts is the JSR 75 PIM API (package javax.microedition.pim). PIM is an optional API on devices, so check for support at runtime with System.getProperty("microedition.pim.version") — a null value means no PIM implementation is available. Behavior and which fields are supported vary by handset, so test on the target Nokia model as well as the emulator. (docs.oracle.com)

Basic working flow (illustrative): obtain the PIM instance, open the CONTACT_LIST in READ_WRITE mode, locate the target Contact, change/add fields, call commit(), and close the list. Handle PIMException, UnsupportedFieldException and SecurityException and always check the ContactList for supported fields before writing. Example pattern:

import javax.microedition.pim.*;
import java.util.Enumeration;

try {
    ContactList cl = (ContactList)PIM.getInstance()
        .openPIMList(PIM.CONTACT_LIST, PIM.READ_WRITE);
    Enumeration it = cl.items();
    while (it.hasMoreElements()) {
        Contact c = (Contact)it.nextElement();
        if (cl.isSupportedField(Contact.FORMATTED_NAME) &&
            "John Doe".equals(c.getString(Contact.FORMATTED_NAME,0))) {
            if (c.countValues(Contact.TEL) > 0) c.removeValue(Contact.TEL,0);
            c.addString(Contact.TEL, Contact.ATTR_MOBILE, "+123456789");
            c.commit();
            break;
        }
    }
    cl.close();
} catch (PIMException | SecurityException e) {
    // handle errors (permission denied, list closed, etc.)
}

The PIM javadocs and examples show the field-checking/commit pattern and the need to use stringArraySize for NAME/ADDR arrays. Test code on emulator first, then on the real phone because device quirks are common. (nikita36078.github.io)

Practical tips and pitfalls: guard all PIM calls with feature checks and try/catch; many phones prompt or block write access unless the MIDlet requests the right permissions (MIDlet-Permissions/MIDlet-Permissions-Opt) and/or is signed and placed in an appropriate security domain. Nokia historically offered publisher signing (OVI/Publisher) as well as the option to use CA-signed certificates for broader trust. If edits are denied on-device but work in the emulator, the issue is almost always permissions/signing or a handset-specific limitation. (docs.oracle.com)

Quick checklist for the original poster: confirm microedition.pim.version, run the PIM example on the emulator, add required MIDlet-Permissions and handle SecurityException, test on the Nokia handset, and if write access is blocked consider signing the MIDlet or using the device manufacturer publishing/signing path (as suggested, this topic also belongs in the software-development forum).

Recommended Answers

All 2 Replies

i am trying to make a program that edits contacts on a Nokia phone using J2ME
but i don't know how to access the contacts help please

so, why did you post in the winVista and win7 forum ,maybe best look in the software developing forum .good luck.
http://www.daniweb.com/software-development/2

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.