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());
}
}