| ID | CS001218 | 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.Calendar, calendar.Export() |
The following 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).
Note: The test device needs to have at least one calendar entry in the calendar.
// 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;
}
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.
The following sample application has been tested in Nokia 5800 XpressMusic (S60 5th edition, Flash Lite 3.0). File:FlashLite Export Calendar Entries.zip
No related wiki articles found