×
Namespaces

Variants
Actions
Revision as of 07:17, 3 October 2012 by hamishwillee (Talk | contribs)

Archived:Exporting calendar entries to a text file in Flash Lite

From Nokia Developer Wiki
Jump to: navigation, search

This code snippet demonstrates how to use the Calendar Service API in a Flash Lite 3.0 application to export calendar entries from the default calendar of the device to an external text file (supported from S60 5th Edition onwards).

Article Metadata
Code ExampleTested with
Devices(s): Nokia 5800 XpressMusic
Compatibility
Platform(s): S60 5th Edition
S60 5th Edition
Article
Keywords: Service.Calendar, calendar.Export()
Created: User:Nokia Developer KB (15 Dec 2008)
Last edited: hamishwillee (03 Oct 2012)

Contents

Preconditions

The test device needs to have at least one calendar entry in the calendar.

Source

// Import Platform Service Interface
import com.nokia.lib.Service;
// Heading of the application
heading_txt.text = "Export Calendar entries";
 
// Create a new Service object which has Calendar data
var calendar = new Service("Service.Calendar", "IDataSource");
 
// Get calendar entries from the default calendar application
// Define input parameters for the List of calendar entries
var inListParams = {Type:"CalendarEntry"};
 
// Define the result value for the List
var outListParams = calendar.GetList(inListParams);
var outList = outListParams.ReturnValue;
var outputListEntry = null;
var idList:Array = new Array();
text_txt.text += "Exported entries: \r";
// Go through all calendar events and push them to the array
do {
outputListEntry = outList.next();
if (null != outputListEntry) {
idList.push(outputListEntry.id);
text_txt.text += "-"+outputListEntry.id+"\r";
} else {
break;
}
} while (true);
 
// Define the input data for the exported text file
var inputData = {IdList:idList, Format:"VCal",
FileName:"c:\\Data\\Others\\example.txt"};
 
// Define the input parameters for export
var inParams = {Type:"CalendarEntry", Data:inputData};
 
// Define the result value
var outParams = calendar.Export(inParams);
if (outParams.ErrorCode == 0) {
text_txt.text += "Export success!";
} else {
var errorId = outParams.ErrorCode;
text_txt.text += "\rError: "+errorId;
}

Postconditions

One exported entry is saved as example.txt in the C:\Data\Others directory. The IDs of all the exported calendar entries are displayed in the application.

Example application

The following sample application has been tested in Nokia 5800 XpressMusic (S60 5th edition, Flash Lite 3.0). File:FlashLite Export Calendar Entries.zip

See also

97 page views in the last 30 days.