Archived:Exporting a contact in Flash Lite
Archived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.
We do not recommend Flash Lite development on current Nokia devices, and all Flash Lite articles on this wiki have been archived. Flash Lite has been removed from all Nokia Asha and recent Series 40 devices and has limited support on Symbian. Specific information for Nokia Belle is available in Flash Lite on Nokia Browser for Symbian. Specific information for OLD Series 40 and Symbian devices is available in the Flash Lite Developers Library.
We do not recommend Flash Lite development on current Nokia devices, and all Flash Lite articles on this wiki have been archived. Flash Lite has been removed from all Nokia Asha and recent Series 40 devices and has limited support on Symbian. Specific information for Nokia Belle is available in Flash Lite on Nokia Browser for Symbian. Specific information for OLD Series 40 and Symbian devices is available in the Flash Lite Developers Library.
This 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. It is supported from S60 5th Edition onwards.
Article Metadata
Code Example
Source file: Media:FlashLite Export Contact.zip
Tested with
Devices(s): Nokia 5800 XpressMusic
Compatibility
Platform(s): S60 5th Edition
Article
Keywords: Service.Contact, contact.Export()
Created: User:Nokia Developer KB
(15 Dec 2008)
Last edited: hamishwillee
(14 May 2013)
Contents |
Preconditions
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.
Source
// 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;
}
Postconditions
Information of the exported contact is displayed. The exported VCard file can be found in the c:\\Data\\Others folder on the device.
Example application
The following sample application has been tested in Nokia 5800 XpressMusic (S60 5th edition, Flash Lite 3.0).
File:FlashLite Export Contact.zip


(no comments yet)