BlackBerry Forums Support Community

BlackBerry Forums Support Community (http://www.blackberryforums.com/)
-   Developer Forum (http://www.blackberryforums.com/developer-forum/)
-   -   Use PIM.getInstance().toSerialFormat to creat a vcard bytestream (http://www.blackberryforums.com/developer-forum/149617-use-pim-getinstance-toserialformat-creat-vcard-bytestream.html)

penck 09-11-2008 10:10 AM

Use PIM.getInstance().toSerialFormat to creat a vcard bytestream
 
Hi everybody
I've got a problem when I used PIM.getInstance().toSerialFormat to creat a bytestream with the form of vcard 2.1. Actually, the code is running well on the simulators; but when I tried to run it on the device(8800), the first 5 or 6 contacts could be well created and then it will get an error (IndexOutofBoundsExceptions) at this setence;
But on the simulator I've tested with a bigger size and a bigger length (contacts);
could anyone give me some suggestion? I'm really crazy for this...

My code:

try
{
ContactList contactList = (ContactList)PIM.getInstance().openPIMList(PIM.CON TACT_LIST,PIM.READ_ONLY);
Enumeration enumer = contactList.items();
while (enumer.hasMoreElements())
{
Contact contact = (Contact)enumer.nextElement();
ByteArrayOutputStream ostream = new ByteArrayOutputStream();
PIM.getInstance().toSerialFormat(contact, ostream,"UTF8",dataFormats[0]);
}
}
catch (Exception e)
{
e.printStackTrace();
}


All times are GMT -5. The time now is 01:21 AM.

Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.