×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    36

    Problem in Adding String array in Contact list

    Hi Frnds....

    I m working on PIM API.I got an Illegal Argument Exception while adding a name by addStringArray method of PIM API.It doesnot appear on emulator .the error is on device.
    My code is:
    Code:
     private void addField(int field) {
           
            String label="";
            try{
            switch (item.getPIMList().getFieldDataType(field)) {
                case PIMItem.STRING:
                    label = item.getPIMList().getFieldLabel(field);
                   
                    item.addString(field, PIMItem.ATTR_NONE, "");
                    break;
                case PIMItem.STRING_ARRAY: {
                    label = item.getPIMList().getFieldLabel(field);
                   
                    int[] supportedElements =
                            item.getPIMList().getSupportedArrayElements(field);
                    int arraySize = 0;
                    
                    for (int i = 0; i < supportedElements.length; i++) {
                        int n=(supportedElements[i] + 1);
                        
                        arraySize = Math.max(arraySize, supportedElements[i] + 1);
                    }
                    
                    String[] a = new String[arraySize];
                    for (int i = 0; i < a.length; i++) {
                       
                        a[i] = "";
                    }
    
                   
                   
                    item.addStringArray(field, PIMItem.ATTR_NONE, a);
                     
                    break;
                }
                case PIMItem.BINARY:
                    label = item.getPIMList().getFieldLabel(field);
                   
                    item.addBinary(field, PIMItem.ATTR_NONE, new byte[16], 0, 16);
                    break;
                case PIMItem.BOOLEAN:
                    label = item.getPIMList().getFieldLabel(field);
                   
                    item.addBoolean(field, PIMItem.ATTR_NONE, false);
                    break;
                case PIMItem.DATE:
                    label = item.getPIMList().getFieldLabel(field);
                  
                    item.addDate(field, PIMItem.ATTR_NONE, new Date().getTime()); 
                    break;
                case PIMItem.INT:
                    label = item.getPIMList().getFieldLabel(field);
                   
                    item.addInt(field, PIMItem.ATTR_NONE, 0);
            }
            }catch(Exception e)
            {
                 Alert a = new Alert("Alert", e.toString(), null, AlertType.INFO);
                a.setTimeout(Alert.FOREVER);
                Display.getDisplay(midlet).setCurrent(a, this);
                
            }
            
        }

  2. #2
    Registered User
    Join Date
    Feb 2007
    Location
    Tampere
    Posts
    370

    Re: Problem in Adding String array in Contact list

    Hi

    Check following example

    If I am not wrong your first parameter in addStringArray is wrong.
    Regards

    - MVP
    "Dare To Dream" - A.P.J.Kalam

Similar Threads

  1. PIM contact list supported array elements
    By gbaballa in forum Mobile Java General
    Replies: 3
    Last Post: 2008-07-09, 13:40
  2. adding a new contact in S40 using java
    By oscarm in forum Mobile Java General
    Replies: 1
    Last Post: 2008-05-13, 09:01
  3. java.lang.ClassCastException error in Eclipse
    By jacky521 in forum Mobile Java General
    Replies: 3
    Last Post: 2007-10-15, 03:18
  4. Problem while adding photo field in contact using jsr-75....
    By pankaj_hotwani in forum Mobile Java General
    Replies: 1
    Last Post: 2006-07-06, 18:56
  5. Replies: 0
    Last Post: 2002-12-11, 09:44

Posting Permissions

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