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


Voltage Electricity Tester Volt Detector Test Pen AC Non-Contact Sensor 90-1000V picture

Voltage Electricity Tester Volt Detector Test Pen AC Non-Contact Sensor 90-1000V

$15.94



100A AC Meter Ammeter Volt Energy Voltage Power LCD Display Monitor Panel picture

100A AC Meter Ammeter Volt Energy Voltage Power LCD Display Monitor Panel

$17.09



Voltage Electric Tester Volt Detector Test Pen Non-Contact Sensor AC DC 12-1000V picture

Voltage Electric Tester Volt Detector Test Pen Non-Contact Sensor AC DC 12-1000V

$7.95



Electricity Usage Energy Monitor Plug Power Watt Voltage Meter Analyzer Socket picture

Electricity Usage Energy Monitor Plug Power Watt Voltage Meter Analyzer Socket

$11.49



12-24V Dual Voltage Round LED Panel Digital Car Voltmeter Ammeter Waterproof USA picture

12-24V Dual Voltage Round LED Panel Digital Car Voltmeter Ammeter Waterproof USA

$12.99



DC 8V-100V Battery Capacity Indicator Voltmeter Voltage Meter Monitor Gauge picture

DC 8V-100V Battery Capacity Indicator Voltmeter Voltage Meter Monitor Gauge

$116.23







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