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


Measurement Computing PCI Multifunction Analog & Digital I/O PCI-DAS1200 picture

Measurement Computing PCI Multifunction Analog & Digital I/O PCI-DAS1200

$49.99



Tektronix 7854 Waveform Calculator. picture

Tektronix 7854 Waveform Calculator.

$199.00



Delta Computer Controls A2 - Analog Input Card for Delta RMC75 EXP70-A2 picture

Delta Computer Controls A2 - Analog Input Card for Delta RMC75 EXP70-A2

$680.00



Vintage ISA Measurement Computing CIO-DAC16 12-bit 16ch Analog Output Board DAQ picture

Vintage ISA Measurement Computing CIO-DAC16 12-bit 16ch Analog Output Board DAQ

$75.00



CNCTOPBAOS 4 Axis Offline Stand Alone CNC Motion Controller System DDCSV3.1 (01) picture

CNCTOPBAOS 4 Axis Offline Stand Alone CNC Motion Controller System DDCSV3.1 (01)

$229.90



Measurement Computing 197728B USB 1608HS-2A0 16-Channel Digital DAQ +2 Analog picture

Measurement Computing 197728B USB 1608HS-2A0 16-Channel Digital DAQ +2 Analog

$422.50







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