Friday, September 20, 2013

Downloading a file remotely hosted on HTTP for Android in Java

This script downloads a file from a remote http location, and places the contents of the file on your device (external or internal directory downloads). The file will appear in your notifications and actually utilize the built-in download manager (as long as you have ANDROID HONEYCOMB BUILD).

public void downloadFile() {
Log.v(TAG, "Downloading File...");
String url = "";
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
request.setDescription("This is the Zip file to download");
request.setTitle("update zip file");
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "");

// get download service and enqueue file
DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);


No comments:

Post a Comment