The Downloader component can be used to download a file straight from the internet to your phone or tablet's local storage.
dwn = app.CreateDownloader(
→ app object:
You can download a file with the Download method which accepts a source url and a target directory: dwn.Download( srcFileUrl, targetDir );
Once the Download method has been called, it show a progress bar with the current download progress. But you can disable this behavior with the “NoDialog” option.
If you want to know when the download process has finished (or failed) you can define a callback functioni with the SetOnComplete method: dload.SetOnComplete( callback );
Example - Example
var srcFileUrl = "http://sgarman.net/downloadable.txt";
var targetDir = "/sdcard";
dload = app.CreateDownloader();
dload.SetOnComplete( dload_OnComplete );
dload.Download( srcFileUrl, targetDir );
The following methods are available on the Downloader object:
string: path to file or folder ( “/absolute/...” or “relative/...” )
string: url path
string: comma “,” separated: “NoDialog” or “Light”
Start downloading a file.
Returns the current download progress.
Returns the target download size in bytes.
Returns the control class name.
Checks if the download has compleated or not.
Allows access to other functions defined on the object in Java via reflection.
Note: This function is a premium feature. Please consider subscribing to Premium to use this feature and support DroidScript in its further development.
Define a callback function which is called when download is cancelled.
Define a callback function which is called when the download is finished.
Define a callback function which is called when the download is downloaded.
Define a callback function which is called when an error occurred while downloading the file.