【发布时间】:2017-04-16 05:57:11
【问题描述】:
我有一个从 YouTube 下载视频的 android 代码,它工作正常,但它将视频文件保存在应用程序文件夹中,我在“视频”公共文件夹中找不到视频
public void onNext(String downloadUrl) {
dismissWaitDialog();
String fileName = fmtStreamMap.title + "." + fmtStreamMap.extension;
/*Added By Morad*/
if (fmtStreamMap.extension.contains("mp3")) {
Uri uri = Uri.parse(downloadUrl);
DownloadManager.Request request = new DownloadManager.Request(uri);
request.setDestinationInExternalFilesDir(MainActivity.this,Environment.DIRECTORY_MUSIC, fileName);
downloadManager.enqueue(request);
} else {
Uri uri = Uri.parse(downloadUrl);
DownloadManager.Request request = new DownloadManager.Request(uri);
request.setDestinationInExternalFilesDir(MainActivity.this,DIRECTORY_MOVIES, fileName);
//request.setDestinationInExternalPublicDir(DIRECTORY_MOVIES, fileName);
downloadManager.enqueue(request);
}
}
我使用了request.setDestinationInExternalPublicDir(DIRECTORY_MOVIES, fileName);,但它不起作用。
【问题讨论】:
-
首先检查文件夹是否存在,如果文件夹不存在则开始下载后创建文件夹。
-
你能修改我的代码吗,,,请
-
downloadUrl的值是多少。使用Log.i()打印它,你的文件应该存储在那个路径中
标签: java android download android-sdcard