HI,
I am trying to access the address book using PIM api. I tried using RIM's PIM api but it said, cannot access the methods due to restrictions on the api. Then I tried using javax.microedition.pim.* api. The code is running find and is not reflecting any error or exception.
But for some reason it is not reading the contacts, everytime I try to see the number of elements fetched I get zero as the answer....
Following is the code that I am using for the purpose:
PHP Code:
PIMList list = null;
String name="";
try {
list = (PIMList)PIM.getInstance().openPIMList(PIM.CONTACT_LIST, PIM.READ_ONLY);
int field = Contact.NAME;
if(list.isSupportedField(field)){
int dataType = list.getFieldDataType(field);
Enumeration contactEnum = list.items();
StringBuffer sb = new StringBuffer();
while(contactEnum.hasMoreElements()){tempo=10;
Contact contact = (Contact)contactEnum.nextElement();
if(dataType == Contact.STRING){
v.addElement(contact.getString(field, 0));
}
else if(dataType == Contact.STRING_ARRAY){
Stringxxx91;xxx93; array = contact.getStringArray(field, 0);
sb.setLength(0);
for(int i=array.length; i>0; i-- ){
sb.append((arrayxxx91;i - 1xxx93; == null ? "" : arrayxxx91;i - 1xxx93;) + " ");
v.addElement(sb.toString());
}
}
}
}
} catch (Exception e) {
// TODO: handle exception
tempo=3;
}
finally{
if(list !=null){
try {
list.close();
} catch (Exception e) {
// TODO: handle exception
tempo=7;
}
}
}
Can anyone please suggest me any thing else...and yeah on more thing the contacts are on the device and not on the memory card incase some one need to know that.....
Hope to hear something gr8....