Back

DownloadFile

Hello World

Downloads a file using the Android's built-in download manager which creates a notification with the current download status and a custom title and description.

app.DownloadFile( source, destination, title, description, options )

In some cases there seems to appear a dialog - you can prevent that using the NoDialog option.

With this methof you won't be able to get a OnComplete callback - if you need that check out CreateDownloader.

Example - Downloading the DroidScript logo

function OnStart()
{
    var src = "http://www.androidscript.org/droidscriptwp/wp-content/uploads/2015/10/droidscript_logo_64x64.png";
    var dst = "/sdcard/Downloads/logo.png";
    app.DownloadFile(src, dst, "MyTitle", "My Description", "NoDialog");
}
Copy All       Run      

Example - Download to external storage

function OnStart()
{
    var src = "http://www.androidscript.org/droidscriptwp/wp-content/uploads/2015/10/droidscript_logo_64x64.png";
    var dst = app.GetExternalFolder() + "/Downloads/logo.png";
    app.DownloadFile(src, dst, "MyTitle", "My Description", "NoDialog");
}
Copy All       Run      
string
string: path to file or folder ( “/absolute/...” or “relative/...” )
string: comma “,” separated: “NoDialog”