private static String downloadUrl = "";
private static String fileName = "";
见下列代码,一看就懂,但是做好放在Service中执行,防止Activity Destory后不下载,Service在下载完后就停止
//创建下载任务
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(downloadUrl));//指定下载路径和下载名
request.setDestinationInExternalPublicDir("/download/", fileName);
//获取下载管理器
DownloadManager downloadManager = (DownloadManager) this.getSystemService(this.DOWNLOAD_SERVICE);
//将下载任务加入下载列表
downloadManager.enqueue(request);