×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Regular Contributor
    Join Date
    Aug 2008
    Location
    Pune
    Posts
    223

    search Contact name using PIM

    Hi All,
    In my application I want to input mobile number and search this number in contact list if it is found then it should give contact name.
    please help me ASAP........

  2. #2
    Regular Contributor
    Join Date
    Apr 2007
    Posts
    220

    Re: search Contact name using PIM

    Hi,

    You can follow these steps-

    1- Create a foram that has a text field to input the phone number and a search button.

    2- As soos as the search button is pressed read the entire ContactList and match for the phone number you are looking for.

    The following code can help you-

    PIM pim = PIM.getInstance();
    ContactList clist;
    try {
    clist = (ContactList) pim.openPIMList(PIM.CONTACT_LIST,PIM.READ_WRITE);
    } catch(Exception e) {
    System.out.println(e);
    }

    // Retrieve contact values
    Enumeration contacts = clist.items();

    Contact c;
    while(contact.hasMoreElements())
    {
    c = (Contact) contacts.nextElement();
    //Here you can check for equality of contact info and if match is found then- return c;

    }


    I Hope this will help you.

    Regards
    Amit

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

    Re: search Contact name using PIM

    Thanx 4 reply amit........
    but i got unhandeled exception...

    code is......

    while(enList.hasMoreElements())
    {
    contact=(Contact)enList.nextElement();
    System.out.println("Number: "+number);
    if(contact.ATTR_MOBILE==(Integer.parseInt(number)))
    {
    String name=contact.getString(contact.FORMATTED_NAME,contact.ATTR_NONE);
    cList.append(name,null);
    }
    }

    please tell me ASAP what is wrong in this code??
    number is of string type getting from textfield.
    I have to match contact's mobile number with this number..
    Thanx...
    Last edited by devdattac; 2008-09-30 at 06:26.

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

    Re: search Contact name using PIM

    Hi devdattac,

    if you get an Exception, then the simplest thing you could do is to try/catch it to find out which kind of Exception it is, and then act properly.

    Hope it helps,
    Pit

Similar Threads

  1. PIM API is giving exception or not reading any contact
    By mobile_expert in forum Mobile Java General
    Replies: 0
    Last Post: 2008-04-25, 15:29
  2. Replies: 2
    Last Post: 2008-01-04, 09:58
  3. About PIM read Email from 5300 contact
    By jack_lu in forum Mobile Java General
    Replies: 0
    Last Post: 2007-12-21, 08:23
  4. Replies: 2
    Last Post: 2007-07-07, 16:02
  5. 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

Posting Permissions

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