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


6802 II Digital Thermocouple Thermometer Dual Channel 2*K-Type Temperature Meter picture

6802 II Digital Thermocouple Thermometer Dual Channel 2*K-Type Temperature Meter

$24.40



Digital Thermometer Dual Channel Input Thermocouple K J T E R N C/F Selection US picture

Digital Thermometer Dual Channel Input Thermocouple K J T E R N C/F Selection US

$25.99



K Type Temperature Sensor Probe 1.5M Cable 4mmx100mm Probe Thermocouple picture

K Type Temperature Sensor Probe 1.5M Cable 4mmx100mm Probe Thermocouple

$17.87



Robertshaw Thermocouple 48

Robertshaw Thermocouple 48" 1980-048 Snap Fit Universal (51-1457)

$15.89



K-Type Thermocouple Probe Digital Thermometer Steel Sensor Spiral Cable  picture

K-Type Thermocouple Probe Digital Thermometer Steel Sensor Spiral Cable

$11.49



TM-902C Digital Sensor LCD Thermometer Single Input K Type Thermocouple Probe picture

TM-902C Digital Sensor LCD Thermometer Single Input K Type Thermocouple Probe

$15.49







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