Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Highlighted
New Developer
New Developer
Posts: 2
Registered: ‎11-05-2008
My Device: Not Specified
Accepted Solution

Contact NAME changes are not persisted on 4.5 and 4.6, am I seeing a bug?

I was wondering if this is a known bug in 4.5 and 4.6. This example works on a 4.2.1 simulator and device, but fails on every 4.5 and 4.6 simulator and device I've tried. When the modified contact is retrieved again, the name still has the original value. Is there any work-around better deleting and re-creating the Contact?

 

BlackBerryContactList contactList = (BlackBerryContactList)PIM.getInstance().openPIMList(PIM.CONTACT_LIST, PIM.READ_WRITE);

Contact contact = (Contact)contactList.createContact();
String[] name = new String[contactList.stringArraySize(Contact.NAME)];
name[Contact.NAME_GIVEN] = "Homer";
name[Contact.NAME_FAMILY] = "Flintstone";
contact.addStringArray(Contact.NAME, Contact.ATTR_NONE, name);
contact.commit();

contact = (Contact)contactList.itemsByName("Homer").nextElement();
name = contact.getStringArray(Contact.NAME, 0);
name[Contact.NAME_FAMILY] = "Simpson";
contact.setStringArray(Contact.NAME, 0, Contact.ATTR_NONE, name); // This does not stick
contact.commit();

contact = (Contact)contactList.itemsByName("Homer").nextElement();
name = contact.getStringArray(Contact.NAME, 0);
System.err.println(name[Contact.NAME_GIVEN] + " " + name[Contact.NAME_FAMILY]);

 

 

 

 

 

BlackBerry Development Advisor
Posts: 15,700
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Contact NAME changes are not persisted on 4.5 and 4.6, am I seeing a bug?

I have been able to reproduce this and have reported it to our development team.  The work around would be as you suggest, which is to delete and re-create the contact.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker