Back

Downloader

The Downloader component can be used to download a file straight from the internet to your phone or tablet's local storage.

Create a Downloader object using the CreateDownloader method of the app object:

 dload = app.CreateDownloader( );

The SetOnComplete method is used to set a function to be called when the download has finished or failed

 dload.SetOnComplete( callback );

The Download method sets the source and destination of the file and starts the download

 dload.Download( srcFileUrl, targetDir );

Once the Download method has been called, it show a progress bar and begins the download

Example

function OnStart()
{
    var srcFileUrl="http://sgarman.net/downloadable.txt";
    var targetDir="/sdcard";

    dload = app.CreateDownloader();
    dload.SetOnComplete( dload_OnComplete );
    dload.Download( srcFileUrl, targetDir );
}

function dload_OnComplete()
{
     app.ShowPopup("Download complete");
}
    Copy     Copy All      Run     

See 'CreateDownloader for more informations and a complete function list