Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

New Developer
Posts: 18
Registered: ‎01-04-2009
My Device: Not Specified

Importing Exporting contacts using vCard

Does BB provide any API to import and export contacts into existing contact list from and to vCard.

BlackBerry Development Advisor
Posts: 15,882
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Importing Exporting contacts using vCard

Yes, refer to the PIM.fromSerialFormat(InputStream is, String enc) and PIM.toSerialFormat(PIMItem item, OutputStream os, String enc, String dataFormat) methods.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
New Member
Posts: 1
Registered: ‎06-13-2011
My Device: 8520
My Carrier: rogers

Re: Importing Exporting contacts using vCard

Could anyone explain me in simple words how to do it?

New Contributor
Posts: 4
Registered: ‎08-29-2011
My Device: BlackBerry Torch 9800
My Carrier: 2degrees

Re: Importing Exporting contacts using vCard

This is what I do:




BlackBerryContactList contactList = (BlackBerryContactList)PIM.getInstance().openPIMList(


String[] dataFormats = PIM.getInstance().supportedSerialFormats(PIM.CONTACT_LIST);
Enumeration enu = contactList.items();
while (enu.hasMoreElements()) {

Contact c = (Contact)enu.nextElement();

ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
PIM.getInstance().toSerialFormat(c, byteStream, null, dataFormats[0]);
String contact = byteStream.toString();






ByteArrayInputStream is = new ByteArrayInputStream(contactStr.getBytes());
PIMItem[] pi = PIM.getInstance().fromSerialFormat(is, null);

ContactList contactList = (ContactList)PIM.getInstance().openPIMList(PIM.CONTACT_LIST, PIM.READ_WRITE);
Contact contact2 = contactList.importContact((Contact)pi[0]);
Enumeration matching = contactList.items(contact2);
if(matching.hasMoreElements()) {
System.out.println("found the first contact");
} else {
System.out.println("adding the first contact");

New Member
Posts: 1
Registered: ‎01-26-2012
My Device: BlackBerry Curve 3G 9300
My Carrier: Vodafone

Re: Importing Exporting contacts using vCard

3reftakshi ana kida 


Simple english pleaseSmiley Frustrated