Android: Download an application using the DownloadManager class

android, download

Solution

Same problem. Solved with a call to:

public DownloadManager.Request setDestinationUri (Uri uri)

You need to have WRITE_EXTERNAL_STORAGE permission.

Uri src_uri = Uri.parse("http://your.url.here/File.apk");
Uri dst_uri = Uri.parse("file:///mnt/sdcard/download/File.apk");

DownloadManager.Request req = new DownloadManager.Request(src_uri);
req.setDestinationUri(dst_uri);
DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
dm.enqueue(req);

Problem

I am trying to download a non-market application in Android using the `DownloadManager` class. what I am doing is the following: ``` DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE); Request request = new Request(Uri.parse("PATH_TO_MY_APP")); long enqueue = dm.enqueue(request); ``` The notification bar shows me that the app is being downloaded. But I am not able to install it or to find it on the device. What I am doing wrong?

Original source

Related problems