×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    36

    Problem in getting Address from address book

    Hi Frndz;
    I m working on PIM.My prob is that I got an arrayIndexOutofBound Exception while accessing the address field of Address book.
    My code is here:
    Code:
    if (contList.isSupportedField(Contact.ADDR))
                 {
                                       addr=contact.getStringArray(Contact.ADDR,0);
                     System.out.println("Address="+addr[0]);
              
           }

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

    Re: Problem in getting Address from address book

    Hi Nemat,

    you should try enclosing the getStringArray() call into a try/catch block, since contacts without an address will throw that kind of Exception, as from PIM API JavaDocs:
    java.lang.IndexOutOfBoundsException - if the index is negative or greater than or equal to the number of values currently contained in the field.
    Hope it helps,
    Pit

  3. #3
    Registered User
    Join Date
    Apr 2008
    Posts
    36

    Re: Problem in getting Address from address book

    Thanx Pit,
    ya I m able to catch the exception.
    So is my way of accessing the address field is correct???
    if yes then I've another query.Actually first I m adding the contact and then I need to get that.If my way of accessing address field is correct then the way of adding address in address book may b wrong.
    Here is my code:
    Code:
    String[] addr=new String[contactList.stringArraySize( contact.ADDR)];
    try{
           addr[0] ="Some address";
       }
    catch(Exception e)
    {
           System.out.println("Exception in adding Address"+e);
    }
    if (contactList.isSupportedField(Contact.ADDR))
    {      
        contact.addStringArray(Contact.ADDR,Contact.ATTR_HOME, addr);
    }
    Plzzzz help me..........

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

    Re: Problem in getting Address from address book

    Hi Nemat,

    on PIM Contact JavaDocs you can find useful examples on how to correctly add new fields, using isSupportedArrayElement() method:

    http://www.forum.nokia.com/document/...m/Contact.html

    Pit

  5. #5
    Registered User
    Join Date
    Apr 2008
    Posts
    36

    Re: Problem in getting Address from address book

    Thanx a lot Pit,
    I've solved my prob......
    Thanx

Similar Threads

  1. Address book match
    By vinayakak in forum Symbian
    Replies: 3
    Last Post: 2008-05-30, 08:23
  2. Address Book
    By skapil in forum Symbian
    Replies: 0
    Last Post: 2004-05-20, 12:25
  3. Problem with reading phone book details in noka 6210
    By master131181 in forum PC Suite API and PC Connectivity SDK
    Replies: 0
    Last Post: 2004-05-02, 14:54
  4. Replies: 1
    Last Post: 2004-04-05, 13:22
  5. query name by phone number from phone's address book
    By Wah in forum Mobile Java General
    Replies: 1
    Last Post: 2003-12-17, 07:09

Posting Permissions

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