×

Discussion Board

Results 1 to 3 of 3

Thread: PIM name field

  1. #1
    Regular Contributor
    Join Date
    Aug 2008
    Location
    Pune
    Posts
    223

    PIM name field

    Hi All,
    I want to access PIM name field in series 60 3rd FP2 devices.can anybody tell me how should I access it?
    I am using 6210 navigator phone.
    please help me ASAP...
    Thanx

  2. #2
    Nokia Developer Champion
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,406

    Re: PIM name field

    Hi devdattac,

    here you will find a complete list of available PIM fields on S60 devices:

    http://www.forum.nokia.com/document/...65DD381F0.html

    Pit

  3. #3
    Super Contributor
    Join Date
    Sep 2008
    Location
    Noida, U.P.
    Posts
    1,330

    Re: PIM name field

    hi devdattac here is a code for writing and reading contact name and mobile number. in the same way u can add more fields supported by device and can read too.
    hope this code will help u.


    /*
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    */

    import java.util.Enumeration;
    import javax.microedition.lcdui.Command;
    import javax.microedition.lcdui.CommandListener;
    import javax.microedition.lcdui.Display;
    import javax.microedition.lcdui.Displayable;
    import javax.microedition.lcdui.Form;
    import javax.microedition.lcdui.List;
    import javax.microedition.lcdui.TextField;
    import javax.microedition.midlet.*;
    import javax.microedition.pim.Contact;
    import javax.microedition.pim.ContactList;
    import javax.microedition.pim.PIM;
    import javax.microedition.pim.PIMException;

    /**
    * @author jitendra
    */
    public class pimMidlet extends MIDlet implements CommandListener,Runnable
    {
    Display dis;
    Form form;
    List list;
    PIM pim;
    ContactList clist;
    Command cmd_read,cmd_write,cmd_exit;
    TextField name_field, number_field;
    Thread thread;
    public pimMidlet()
    {
    dis = Display.getDisplay(this);
    form = new Form("");
    list=new List(null,List.IMPLICIT);
    // Open default contact list
    pim = PIM.getInstance();
    cmd_read = new Command ("Read",Command.SCREEN,1 );
    cmd_write = new Command ("Write",Command.SCREEN,1 );
    cmd_exit = new Command ( "Exit",Command.EXIT,2);
    name_field = new TextField("Enter Name", "", 30, TextField.ANY);
    number_field= new TextField("Enter Number", "", 10, TextField.PHONENUMBER);
    form.addCommand(cmd_write);
    form.addCommand(cmd_read);
    form.addCommand(cmd_exit);
    form.append(name_field);
    form.append(number_field);
    form.setCommandListener(this);
    try{
    clist = (ContactList) pim.openPIMList(PIM.CONTACT_LIST, PIM.READ_WRITE);
    }catch (PIMException pe)
    {
    pe.toString();
    }
    }
    public void startApp()
    {
    dis.setCurrent(form);
    }


    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    }
    public void readContact()
    {
    // Retrieve contact values
    // The countValues() method returns the number of data values currently
    // set in a particular field.

    try {

    Enumeration contacts = clist.items();
    while (contacts.hasMoreElements()) {
    Contact c = (Contact) contacts.nextElement();
    int phoneNumbers = c.countValues(Contact.TEL);
    for (int i = 0; i < phoneNumbers; i++) {
    if (c.getAttributes(Contact.TEL, i) != 0 && Contact.ATTR_MOBILE != 0) {
    String str = c.getString(Contact.TEL, i);
    System.out.println("conact ==="+ str);
    String str1=c.getString(Contact.FORMATTED_NAME, i);
    list.append(str1+" : "+str,null);
    }
    }
    }
    } catch (PIMException pe) {
    pe.toString();
    System.out.println("errorrrrrrrrr");
    }


    dis.setCurrent(list);

    }
    public void addContact()
    {
    thread = new Thread(this);
    thread.start();

    }
    public void run()
    {
    String name = name_field.getString().trim();
    String number = number_field.getString().trim();
    Contact con = clist.createContact();
    con.addString(Contact.FORMATTED_NAME, Contact.ATTR_NONE, name);
    con.addString(Contact.TEL, Contact.ATTR_MOBILE, number);
    try{
    con.commit();
    }catch(PIMException pe)
    {
    pe.toString();
    System.out.println("errrrrrrorrrrrrrrr");
    }
    }

    public void commandAction(Command command, Displayable displayable)
    {
    if ( command == cmd_write)
    {
    if (!name_field.getString().equals("")&& !number_field.getString().equals(""))
    addContact();
    }
    if (command == cmd_read)
    readContact();
    if (command == cmd_exit)
    {
    notifyDestroyed();
    destroyApp(true);
    }

    }

    }

Similar Threads

  1. UnSupported Field exception:105 in PIM
    By devdattac in forum Mobile Java Tools & SDKs
    Replies: 4
    Last Post: 2008-10-02, 06:30
  2. Pim API fields on Series 40
    By ianstrain in forum Mobile Java General
    Replies: 0
    Last Post: 2007-09-25, 18:37
  3. PIM API: updating contact causes a reboot on 6270!
    By suzier in forum Mobile Java General
    Replies: 8
    Last Post: 2007-04-03, 07:29
  4. JSR-75 PIM Access Problem on 6230i
    By CWFR in forum Mobile Java General
    Replies: 1
    Last Post: 2005-10-21, 12:59

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×