BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 10-14-2008, 02:43 AM   #1
abhsax1978@hotmail.com
Thumbs Must Hurt
 
abhsax1978@hotmail.com's Avatar
 
Join Date: Jun 2008
Location: NOIDA
Model: 8100
OS: 4.2.1.91
PIN: 2052AEF9
Carrier: Soft. Engg.
Posts: 111
Unhappy adding NAME in the Contact

Please Login to Remove!

I can add the EMail in the contacts book but I get IllegalArgumentException
when I try to add mobile phone, work phone and NAME[salutations,firstName,lastName]
can anybody tell what's wrong in my code ?
Code:
while (index < recCount) {
            contact = _contactList.createContact();
            /////////////////////////

            // Contact.TEL[ Contact.ATTR_MOBILE, Contact.ATTR_WORK]
            //  Contact.EMAIL;Contact.NAME[Contact.NAME_PREFIX, Contact.NAME_GIVEN, Contact.NAME_FAMILY]

            //////////////////////////
            try {
                if (_contactList.isSupportedField(Contact.EMAIL)) {
                    contact.addString(Contact.EMAIL, 0, email_name + index + "@" + email_domain);
                }
                if (_contactList.isSupportedAttribute(Contact.TEL, Contact.ATTR_MOBILE)) {
                    if (_contactList.isSupportedField(Contact.TEL)) {
                         contact.addInt(Contact.TEL, Contact.ATTR_MOBILE, (int) mobile + index);
                    }
                    if (_contactList.isSupportedField(Contact.ATTR_MOBILE)) {
                         contact.addInt(Contact.TEL, Contact.ATTR_MOBILE, (int) mobile + index);
                    }
                   
                }
                if (_contactList.isSupportedAttribute(Contact.TEL, Contact.ATTR_WORK)) {
                    contact.addInt(Contact.TEL, Contact.ATTR_WORK, (int) work_phone + index);
                }

                strArrName[Contact.NAME_PREFIX] = name_prefix;
                strArrName[Contact.NAME_GIVEN] = name_given + index;
                strArrName[Contact.NAME_FAMILY] = name_family + index;
//                int field=contact.getFields();
                if (_contactList.isSupportedArrayElement(Contact.NAME, Contact.NAME_PREFIX)) {
                    if (_contactList.isSupportedArrayElement(Contact.NAME, Contact.NAME_GIVEN)) {
                        if (_contactList.isSupportedArrayElement(Contact.NAME, Contact.NAME_FAMILY)) {

                            contact.addStringArray(Contact.NAME, 1, strArrName);
                        }
                    }
                }

                contact.commit();

                contact = null;
                index++;
            } catch (Exception ex) {
                System.out.println(className + ":" + ex.toString());
            }


        }
__________________
having new s for developers!!!
Offline  
Old 10-14-2008, 02:59 AM   #2
Ivanov
Talking BlackBerry Encyclopedia
 
Join Date: Apr 2008
Location: Germany, BW
Model: -
PIN: N/A
Carrier: -
Posts: 310
Default

Tel. numbers are Strings not Integers.

Code:
ContactList contactList = (ContactList)PIM.getInstance().openPIMList(PIM.CONTACT_LIST, PIM.WRITE_ONLY);
Contact contact = contactList.createContact();
String[] name = new String[contactList.stringArraySize(Contact.NAME)];
// Add values to PIM item.
name[Contact.NAME_GIVEN] = con.FirstName;
name[Contact.NAME_FAMILY] = con.LastName;

contact.addStringArray(Contact.NAME, Contact.ATTR_NONE, name);
contact.addString(Contact.EMAIL, Contact.ATTR_HOME, con.Email);
contact.addString(Contact.TEL, Contact.ATTR_WORK, con.TelWork);
contact.addString(Contact.TEL, Contact.ATTR_MOBILE, con.TelWork);
contact.addString(Contact.ORG, Contact.ATTR_NONE, con.Organization);
contact.addString(Contact.NOTE, Contact.ATTR_NONE, con.Note);

// Save data to address book.
contact.commit();
__________________
Blessed is the end user who expects nothing, for he/she will not be disappointed. (Franklin's Rule)
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


10 x  SIEMENS QA120AFCN PLUG ON NEUTRAL 20A AFCI ARC FAULT BREAKERS NEW picture

10 x SIEMENS QA120AFCN PLUG ON NEUTRAL 20A AFCI ARC FAULT BREAKERS NEW

$329.95



LOT OF 10 SIEMENS QA115AFCN 15A AFCI PLUG ON NEUTRAL (NO PIGTAIL WIRE) NEW picture

LOT OF 10 SIEMENS QA115AFCN 15A AFCI PLUG ON NEUTRAL (NO PIGTAIL WIRE) NEW

$358.99



Siemens 3RT1046-1AP60 Contactor picture

Siemens 3RT1046-1AP60 Contactor

$387.00



SIEMENS 6ES7 214-1AG40-0XB0 / 6ES72141AG400XB0 SIMATIC S7-1200 CPU 1214C picture

SIEMENS 6ES7 214-1AG40-0XB0 / 6ES72141AG400XB0 SIMATIC S7-1200 CPU 1214C

$199.99



SIEMENS MICROMASTER 440 6SE6440-2UD21-1AA1 INVERTER DRIVE picture

SIEMENS MICROMASTER 440 6SE6440-2UD21-1AA1 INVERTER DRIVE

$295.00



LOT OF 10 SIEMENS Q115DF 15A DUAL FUNCTION AFCI/GFCI BREAKERS NEW picture

LOT OF 10 SIEMENS Q115DF 15A DUAL FUNCTION AFCI/GFCI BREAKERS NEW

$439.99







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