Join Now
Quality Rating:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

This page was last modified 13:09, 24 January 2008.

How to list extended fields of ContactList

From Forum Nokia Wiki


When using PIM API and its ContactList class, it is important to find out first, what fields are supported by the implementation. This can be done by using the instructions shown here: How to list the supported fields in a PIMList.

It is also possible, that implementations have so called extended fields. They are additional fields, which are not listed as standard fields of Contact class. Some of the latest S60 implementations (S60 3rd Ed FP1 and newer) support a wide selection of these fields. Below is a method for creating a contact, which has a name "Test Contact" and all the extended attributes, which are available. This method has been tested in S60 3rd Edition FP1 devices like N95.

public void testExtendedFields() {
	ContactList list = null;
	Contact contact = null;
	try {       
		list = (ContactList)PIM.getInstance().openPIMList(PIM.CONTACT_LIST, PIM.READ_WRITE);
		contact = list.createContact();
		String[] name = new String[list.stringArraySize(Contact.NAME)];
		if (list.isSupportedArrayElement(Contact.NAME, Contact.NAME_FAMILY)) name[Contact.NAME_FAMILY] = "Contact";
		if (list.isSupportedArrayElement(Contact.NAME, Contact.NAME_GIVEN)) name[Contact.NAME_GIVEN] = "Test";
		contact.addStringArray(Contact.NAME, PIMItem.ATTR_NONE, name);
		int fields[] = list.getSupportedFields();
		for (int i = 0; i < fields.length; i++) {
			if (fields[i] > 256) { // extended field
				if (fields[i] == 16797704) { // Anniversary field
					contact.addDate(fields[i], Contact.ATTR_NONE, new java.util.Date().getTime());
				}
				else contact.addString(fields[i], Contact.ATTR_NONE, "field: " + fields[i]);
			}
		}
		contact.commit();
		list.close();
	} catch (PIMException pe) {
		System.out.println("PIMException: " + pe.getMessage());
	} catch (IllegalArgumentException iae) {
		System.out.println("IllegalArgumentException: " + iae.getMessage());
}

Note: The existence of extended fields is tested by checking, if the integer value of a field is more then 256.

Note: The field having value of 16797704 (Anniversary field) accepts only a Date object as its content, others accept Strings.

See also: How to add a video clip to a contact in Java ME.

Related Discussions
Thread Thread Starter Forum Replies Last Post
TCoeInputCapabilities tolnaisz General Symbian C++ 0 2002-12-17 14:24
6590 not receiving push messages from external gateway avero General Browsing 1 2002-11-11 12:53
how can i get information from an exiting contact? chinadeng Mobile Java General 2 2007-06-12 10:32
Nokia6630 Bluetooth Features? MarcusLim Bluetooth Technology 2 2004-12-30 11:59
What is the meaning of SMSC in MMSC CDR header ? ask_expert General Messaging 1 2002-06-18 15:44
 
Powered by MediaWiki