BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 07-26-2008, 03:26 AM   #1 (permalink)
Thumbs Must Hurt
 
baran_khan's Avatar
 
Join Date: Apr 2008
Model: 9500
PIN: N/A
Carrier: Airtel
Posts: 110
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Cannot Fetch ATTR_MOBILE parameter from address book

Please Login to Remove!

HI,

I am trying to fetch the mobile number of the contact from the address book.

When I try following command:
phone= contact.getString(Contact.TEL, Contact.ATTR_FAX);

it works fine and fetch me the fax number of the contact, but when I replace "ATTR_FAX" with "ATTR_MOBILE" am getting null in return. Although I have filled all the values in the address book for the contact.

Any idea bout where I might be wrong????
__________________
Smart People ask for Help!!!
Offline  
Old 07-28-2008, 05:40 AM   #2 (permalink)
Thumbs Must Hurt
 
baran_khan's Avatar
 
Join Date: Apr 2008
Model: 9500
PIN: N/A
Carrier: Airtel
Posts: 110
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by baran_khan View Post
HI,

I am trying to fetch the mobile number of the contact from the address book.

When I try following command:
phone= contact.getString(Contact.TEL, Contact.ATTR_FAX);

it works fine and fetch me the fax number of the contact, but when I replace "ATTR_FAX" with "ATTR_MOBILE" am getting null in return. Although I have filled all the values in the address book for the contact.

Any idea bout where I might be wrong????
Ok...here is the code...can anyone plz explain where am I going wrong...i got this code working if I fetch a fax number for the same contact...but will return null if I look for the mobile number instead of the fax...

PHP Code:
                    list = PIM.getInstance().openPIMList(PIM.CONTACT_LISTPIM.READ_ONLY);

                    
Enumeration contactEnum = list.items();


                    while(
contactEnum.hasMoreElements()){
                        
                        
temps++;
                        
Contact contact = (Contact)contactEnum.nextElement();
                        
intxxx91;xxx93; fieldIds contact.getFields();
                        
int id;
                        
name contact.getStringArray(contact.NAME0);
                        
phonecontact.getString(Contact.TELContact.ATTR_MOBILE);
                        
                    } 
Thanks in advance!!!
__________________
Smart People ask for Help!!!
Offline  
Old 07-28-2008, 03:03 PM   #3 (permalink)
New Member
 
Join Date: Jun 2008
Model: 7290
PIN: N/A
Carrier: Cingular
Posts: 14
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

The attribute constant isn't the same as the index number. I'm assuming you're getting an arrayindexoutofbounds exception or nullreference exception. Best way I can think of is to do something like:

Code:
for(int y=0; y < contact.countValues(Contact.TEL); y++)
{
    if(contact.getAttributes(Contact.TEL, y) == Contact.ATTR_MOBILE)
        phone = contact.getString(Contact.TEL, y);  
}
The reason the fax attribute constant is working is that it happens to be low enough to be an actual index.

EDIT: Sorry, that's a lowercase c on contact.getAttributes.

Last edited by PaoloLim : 07-28-2008 at 03:06 PM.
Offline  
Old 07-30-2008, 05:54 AM   #4 (permalink)
Thumbs Must Hurt
 
baran_khan's Avatar
 
Join Date: Apr 2008
Model: 9500
PIN: N/A
Carrier: Airtel
Posts: 110
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by PaoloLim View Post
The attribute constant isn't the same as the index number. I'm assuming you're getting an arrayindexoutofbounds exception or nullreference exception. Best way I can think of is to do something like:

Code:
for(int y=0; y < contact.countValues(Contact.TEL); y++)
{
    if(contact.getAttributes(Contact.TEL, y) == Contact.ATTR_MOBILE)
        phone = contact.getString(Contact.TEL, y);  
}
The reason the fax attribute constant is working is that it happens to be low enough to be an actual index.

EDIT: Sorry, that's a lowercase c on contact.getAttributes.
HI,

Sorry for not replying you this long...was on holiday...u know what it actually works...but I am not really satisfied with the way they are dealing with this....instead of doing it this way..they should have maintained the index names associated with the values that are being stored...instead of having it changed every time we make a change in the contacts...but I guess this is for saving the memory...

Thanks for ur support..i ll look forward for such responses and hope we can share a bag full of knowledge in future.....
__________________
Smart People ask for Help!!!
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.