| ID | CS001219 | Creation date | December 15, 2008 |
| Platform | S60 5th Edition | Tested on devices | Nokia 5800 XpressMusic |
| Category | Flash Lite | Subcategory | S60 Platform Services |
| Keywords (APIs, classes, methods, functions): Service.Contact, contact.Export() |
The following code snippet demonstrates how to use the Contact Service API in Flash Lite 3.0 application to export a contact from the phonebook to a VCard file (supported from S60 5th Edition onwards).
Note: For a successful contact export with this application you need to have the contact information for Eric Example in your phonebook. Only first name and last name are mandatory information.
// Import Platform Service Interface
import com.nokia.lib.Service;
// Heading of the application
heading_txt.text = "Export Contact";
// Create new Service object which has Calendar data
var contact = new Service("Service.Contact", "IDataSource");
// Define input parameters for the list
var inParams = {Type:"Contact"};
// Define result value
var outParams = contact.GetList(inParams);
if (outParams.ErrorCode == 0) {
var outList = outParams.ReturnValue;
var outputEntry = null;
do {
outputEntry = outList.next();
if (null != outputEntry) {
// Get firstname and lastname of the contact
var firstname = outputEntry.FirstName["Value"];
var lastname = outputEntry.LastName["Value"];
var phone = outputEntry.LandPhoneHome["Value"];
// Take the ID from the contact which you like to export to the
// VCard
if(firstname == "Eric" && lastname == "Example") {
var contactId = outputEntry.id;
text_txt.text += "Contact information for VCard:\r";
text_txt.text += "First name: "+firstname+"\r";
text_txt.text += "Last name: "+lastname+"\r\r";
}
} else {
break;
}
} while (true);
} else {
// if errors trace them to the textfield
var errorId = outParams.ErrorCode;
text_txt.text += "Error while listing: "+errorId+"\r";
}
// Define the VCard file for export
var inputData = {DestinationFile:"c:\\Data\\Others\\contact.vcf",
id:contactId};
var inExportParams = {Type:"Contact", Data:inputData};
var outExportParams = contact.Export(inExportParams);
if (outExportParams.ErrorCode == 0) {
text_txt.text += "Export success!";
} else {
var errorId2 = outExportParams.ErrorCode;
text_txt.text += "Error while exporting: "+errorId2;
}
Information of the exported contact is displayed. The exported VCard file can be found in the c:\\Data\\Others folder on the device.
The following sample application has been tested in Nokia 5800 XpressMusic (S60 5th edition, Flash Lite 3.0).
File:FlashLite Export Contact.zip
No related wiki articles found