It easy to read contact on blackberry mobile plz use this following code that read most of parameter that we need to developed mobile app.
System.out.println("********************************************");
try{
String numberWork="",numberHome="",numberMobile="",numberOther="",numberPager="",numberFax="";
BlackBerryContactList contactList = (BlackBerryContactList) PIM.getInstance().openPIMList(PIM.CONTACT_LIST, PIM.READ_ONLY);
Enumeration enumContacts = contactList.items();
while (enumContacts.hasMoreElements()) {
BlackBerryContact c = (BlackBerryContact) enumContacts.nextElement();
if ((contactList.isSupportedField(BlackBerryContact.NAME))
&& (c.countValues(BlackBerryContact.NAME) > 0)) {
name = c.getStringArray(BlackBerryContact.NAME, 0);
String firstName = name[BlackBerryContact.NAME_GIVEN];
String lastName = name[BlackBerryContact.NAME_FAMILY];
String fullname = "";
if (firstName != null) {
fullname += firstName + " ";
}
if ((contactList.isSupportedField(BlackBerryContact.TEL))
&& (c.countValues(BlackBerryContact.TEL) > 0)) {
int numValues = 0;
try {
numValues = c.countValues(BlackBerryContact.TEL);
} catch (Exception localException) {
}
for (int i = 0; i < numValues; ++i) {
if (c.getAttributes(BlackBerryContact.TEL, i) == BlackBerryContact.ATTR_WORK)
numberWork = c.getString(BlackBerryContact.TEL, i);
else if (c.getAttributes(BlackBerryContact.TEL, i) == BlackBerryContact.ATTR_HOME)
numberHome = c.getString(BlackBerryContact.TEL, i);
else if (c.getAttributes(BlackBerryContact.TEL, i) == BlackBerryContact.ATTR_MOBILE)
numberMobile = c
.getString(BlackBerryContact.TEL, i);
else if (c.getAttributes(BlackBerryContact.TEL, i) == BlackBerryContact.ATTR_OTHER)
numberOther = c.getString(115, i);
else if (c.getAttributes(BlackBerryContact.TEL, i) == BlackBerryContact.ATTR_PAGER)
numberPager = c.getString(BlackBerryContact.TEL, i);
else if (c.getAttributes(BlackBerryContact.TEL, i) == BlackBerryContact.ATTR_FAX) {
numberFax = c.getString(BlackBerryContact.TEL, i);
}
}
System.out.println("Mobile Number: "+ numberMobile);
System.out.println("Work Number: " + numberWork);
System.out.println("Home Number: " + numberHome);
System.out.println("Numebr Pager " + numberPager);
System.out.println("Fax Number" + numberFax);
System.out.println("Other Number" + numberOther);
}
}
}
}catch(Exception e){
System.out.println(e);
}
System.out.println("********************************************");
Hope it save your development time.