Welcome!

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

Native Development

Reply
Developer
Posts: 36
Registered: ‎06-28-2012
My Device: BB10
My Carrier: RIM
Accepted Solution

Problem occurred while parsing vcard

Hi,

 

I am having a vcard file(.vcf file) and when i try to parse that vcard using contactFromVCard("asset:///newfile.vcf") method, the returned contact object is always empty.

 

So i checked Contact::isValid() method to check whether contact is valid or not. It is showing that contact is invalid and not able to get any contact information from that object. 

 

I tried to parse vcard with different versions (2.1 and 3.0) but i am always getting contact as a invalid.

 

Evenif I tried to generate vcard using contactToVCard(c.id()) method and parse that generated vcard using above method, i am getting contact as a invalid.

 

Format of vcard is as follow which i am using for parsing : 

 

BEGIN:VCARD
VERSION:3.0
PRODID:-//Research In Motion//RIM App//EN
UID:6
FN:Test Trst
N:Trst;Test;;;
TEL;TYPE=CELL:9999999999
END:VCARD 

 

What should be the problem??

 

Thanks

 

Regular Contributor
Posts: 76
Registered: ‎07-31-2012
My Device: Blackberry
My Carrier: Vodafone

Re: Problem occurred while parsing vcard

[ Edited ]

Hi sanshah90,

 

contactFromVCard method takes vCardData as argument not file path of the vcf. Use QFile to read file data pass it as method argument.

 

QFile file("filepath");
file.open(QIODevice::ReadWrite);
Contact c = ContactService().contactFromVCard(file.readAll());
file.close();