List of all Iphone and Blackberry Development codes in a one click Iphone,objective C,xcode,blackberry Development,iOS Development

Monday, April 16, 2012

Get contacts from Blackberry Contacts





  1. BlackBerryContactList contList;
    try {
    contList = BlackBerryContactList)PIM.getInstance().openPIMList(PIM.CONTACT_LIST,PIM.READ_ONLY);
    Enumeration er = contList.items();
    while (er.hasMoreElements())
     {
    BlackBerryContact c = (BlackBerryContact)er.nextElement();
    if ((contList.isSupportedField(Contact.NAME)) && (c.countValues(Contact.NAME) > 0))
     {
    String[] name = c.getStringArray(Contact.NAME, 0);
    String firstName = name[Contact.NAME_GIVEN];
            String lastName = name[Contact.NAME_FAMILY];
                  
    //here is the code snippet to iterate all phone nrs of a contact
    if ((contList.isSupportedField(Contact.TEL)) && (c.countValues(Contact.TEL) > 0)) {
     int numValues = 0;
      try {
               numValues = c.countValues(Contact.TEL);
             } catch (Exception localException) {
     }
                  
    for (int i = 0; i < numValues; ++i) {
       if (c.getAttributes(Contact.TEL, i) == Contact.ATTR_MOBILE)
                 mobilenumber = c.getString(Contact.TEL, i);
              }
                                         }
     Dialog.alert(firstName+" "+lastName +"  "+mobilenumber);
          }
      }
    } catch (PIMException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }






        

No comments:

Post a Comment