j2me ContactList.commit() error

87 Views Asked by At

I have an application which use to write contacts using ContactList.commit(). I am using this app on 2 different mobiles, one is Nokia X2-02 and other Samsung DUOS E2252. When I use this code in Samsung DUOS, it goes inside if statement that means it supports these fields of Contact.TEL and Contact.ATTR_MOBILE, and probably also executes c.addString(...) statement. But when committing using c.commit() it throws PIMException and simply ignores the whole contact, while using the same application in Nokia phone it works fine. I wonder if Samsung doesn't supports ATTR_MOBILE field, it should simply ignore that filed but instead of that it throws exception and ignores the whole contact. What I want to do is simply ignore that particular field if it doesn't add that or whatever rather than ignoring the contact. My code for this portion is below

if (clist.isSupportedField(Contact.TEL)) {
                if ((clist.isSupportedAttribute(Contact.TEL, Contact.ATTR_HOME)) && (contact.getPhoneHome() != null)) {
                    c.addString(Contact.TEL, Contact.ATTR_HOME, contact.getPhoneHome());
                }
                if ((clist.isSupportedAttribute(Contact.TEL, Contact.ATTR_PAGER)) && (contact.getPager() != null)) {
                    c.addString(Contact.TEL, Contact.ATTR_PAGER, contact.getPager());
                }
                if ((clist.isSupportedAttribute(Contact.TEL, Contact.ATTR_MOBILE)) && (contact.getPhoneMobile() != null)) {
                    c.addString(Contact.TEL, Contact.ATTR_MOBILE, contact.getPhoneMobile());
                }
      }   c.commit();
0

There are 0 best solutions below