×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Aug 2007
    Posts
    31

    Red face save contact name

    i can acces my phone contacs list and create a contact, i can save the phone number and an email, but i can't save the contact name, because this name is a diferent form that the one the phone uses to organize the contacs, and so the new contact in the contact list of the phone appears to be unnamed. i used the next code:

    Code:
    void crearContacto()  {
    		PIM pim = PIM.getInstance();
    		PIMList list = null;
    		String[] allLists = pim.listPIMLists(PIM.CONTACT_LIST);
    		ContactList clist = null;
    		try {
    //		   clist = (ContactList) pim.openPIMList(PIM.CONTACT_LIST, PIM.READ_WRITE,"PHONE");
    		   list = PIM.getInstance().openPIMList(PIM.CONTACT_LIST, PIM.READ_WRITE, allLists[0]);
    		   clist = (ContactList) PIM.getInstance().openPIMList(PIM.CONTACT_LIST, PIM.READ_WRITE, allLists[0]);
    		} catch(Exception e) {
    		   // security or other exception
    		}
    		
    //		Add contact values
    		Contact c = clist.createContact();
    		int attrs = Contact.ATTR_PREFERRED;
    		c.addString(Contact.TEL, attrs, "3-799-1313");
    //		 Some fields can be added without attributes
    		c.addString(Contact.FORMATTED_NAME, PIMItem.ATTR_NONE,  "abc name");
    		
    		c.addString(Contact.EMAIL, PIMItem.ATTR_NONE, "abc@asb.com");
    
    		try {
    			c.commit();
    		} catch (PIMException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		}
    	}
    someone knows how i have to save the contact name to correct this.
    thanks

  2. #2
    Super Contributor
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,191

    Re: save contact name

    Have you tried using the field NAME instead of FORMATTED_NAME? I have seen something about this but I cannot remember exactly, sorry.

    Hartti

  3. #3
    Registered User
    Join Date
    Aug 2007
    Posts
    31

    Re: save contact name

    hi hartti
    when i use NAME appear the next error:

    illegal argument java/lang/illegalargumntexception invalid field.

  4. #4
    Super Contributor
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,191

    Re: save contact name

    WHich phone are you using. S60?
    On the java ME developers library there is a note
    http://www.forum.nokia.com/document/...65DD381F0.html

    "The values set in the Contact.FORMATTED_NAME field through the API are not written to the database. The value in the Contact.FORMATTED_NAME field is set by the API from the values in Contact.NAME string array field elements whenever a Contact is committed or refreshed from the database."

    and

    The supported Contact.NAME string array elements are the following:

    Table 33: The supported Contact.NAME string array elements

    Contact.NAME element Corresponding Phonebook field

    Contact.NAME_FAMILY Last name

    Contact.NAME_GIVEN First name

    Contact.NAME_OTHER Middle

    Contact.NAME_PREFIX Prefix

    Contact.NAME_SUFFIX Suffix

    Last name reading* (element id 5) Last name reading

    First name reading* (element id 6) First name reading

    Hartti

  5. #5
    Registered User
    Join Date
    Aug 2007
    Posts
    31

    Re: save contact name

    hi
    i´m using a S40, and when i use the Contact.NAME, appears the same error
    Last edited by oscarm; 2007-09-19 at 21:58.

Similar Threads

  1. PIM API: updating contact causes a reboot on 6270!
    By suzier in forum Mobile Java General
    Replies: 8
    Last Post: 2007-04-03, 07:29
  2. Save a Contact In the SIM
    By prabaths in forum OMA DM/DS/CP
    Replies: 0
    Last Post: 2007-01-12, 05:33
  3. Replies: 3
    Last Post: 2006-10-09, 12:24
  4. Replies: 1
    Last Post: 2005-05-26, 14:22

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×