Reputation: 598
I use the download manager to download a file and install it.
I'm curious if there is a way to remove it from the downloads history without actually deleting the file from disk?
As far as I know there is no callback to tell if the user installed the file or not so I would like to leave it on disk, but remove it from the downloads history only.
Here is my download code:
// Create download manager final DownloadManager.Request request = new DownloadManager.Request(Uri.parse(appURL));
// Save to here
request.setDestinationUri(this.apkUri);
// Retrieve system download service
final DownloadManager manager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
// Queue request
manager.enqueue(request);
// Will fire off and perform installation when download completes
BroadcastReceiver onComplete = new BroadcastReceiver()
{
@Override
public void onReceive(Context ctxt, Intent intent)
{
performInstall();
ctxt.unregisterReceiver(this);
//finish();
}
};
context.registerReceiver(onComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
And one other thing I'm curious about is in my broadcast receiver is finish() necessary? I'm calling this from a helper class so I can't access the finish function inside of it for some reason.
Upvotes: 0
Views: 1084
Reputation: 86
Before queueing :
OnReceive callback :
Result : file still on disk and DM cleaned
Upvotes: 0