BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 07-26-2008, 02:26 AM   #1
baran_khan
Thumbs Must Hurt
 
baran_khan's Avatar
 
Join Date: Apr 2008
Model: 9500
PIN: N/A
Carrier: Airtel
Posts: 110
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, 04:40 AM   #2
baran_khan
Thumbs Must Hurt
 
baran_khan's Avatar
 
Join Date: Apr 2008
Model: 9500
PIN: N/A
Carrier: Airtel
Posts: 110
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, 02:03 PM   #3
PaoloLim
New Member
 
Join Date: Jun 2008
Model: 7290
PIN: N/A
Carrier: Cingular
Posts: 14
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 02:06 PM..
Offline  
Old 07-30-2008, 04:54 AM   #4
baran_khan
Thumbs Must Hurt
 
baran_khan's Avatar
 
Join Date: Apr 2008
Model: 9500
PIN: N/A
Carrier: Airtel
Posts: 110
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



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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


CBB60 Motor Run Capacitor 450VAC 10uF/20uF/30uF/40uF/50uF 4 Pins CE Standard picture

CBB60 Motor Run Capacitor 450VAC 10uF/20uF/30uF/40uF/50uF 4 Pins CE Standard

$8.99



CBB60 Capacitor 250VAC 60UF MFD For Motor Run 2 Wires Metallized Polypropylene picture

CBB60 Capacitor 250VAC 60UF MFD For Motor Run 2 Wires Metallized Polypropylene

$12.99



CBB60 Capacitor 450VAC 50UF MFD For Motor Run 2 Wires Metallized Polypropylene picture

CBB60 Capacitor 450VAC 50UF MFD For Motor Run 2 Wires Metallized Polypropylene

$12.99



CBB60 Capacitor 250VAC 50UF MFD For Motor Run 2 Wires Metallized Polypropylene picture

CBB60 Capacitor 250VAC 50UF MFD For Motor Run 2 Wires Metallized Polypropylene

$12.49



6.3V 10V 16V 25V 35V 50V 100V 400V SMD Aluminum Electrolytic Capacitor 1-1000 UF picture

6.3V 10V 16V 25V 35V 50V 100V 400V SMD Aluminum Electrolytic Capacitor 1-1000 UF

$155.59



CBB61 250V  Capacitor 2 wires 1/2/3/3.5/4/5/6/7/8/9/10/12/15/18/20/24/25/30 UF picture

CBB61 250V Capacitor 2 wires 1/2/3/3.5/4/5/6/7/8/9/10/12/15/18/20/24/25/30 UF

$129.95







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