gpt4 book ai didi

java - 将电影文件保存在特定文件夹中 -android-

转载 作者:太空宇宙 更新时间:2023-11-04 11:34:30 25 4
gpt4 key购买 nike

我有一个用于从 YouTube 下载视频的 Android 代码,它工作正常,但它将视频文件保存在应用程序文件夹中,并且我在“视频”公共(public)文件夹中找不到该视频

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); 但它不起作用。

最佳答案

  public void onNext(String downloadUrl)
{
dismissWaitDialog();

String fileName = fmtStreamMap.title + "." + fmtStreamMap.extension;

/*Added By Morad*/

if (fmtStreamMap.extension.contains("mp3")){
check_folder(Environment.DIRECTORY_MUSIC);
Uri uri = Uri.parse(downloadUrl);
DownloadManager.Request request = new DownloadManager.Request(uri);
request.setDestinationInExternalFilesDir(MainActivity.this,Environment.DIRECTORY_MUSIC, fileName);
downloadManager.enqueue(request);
}else{
check_folder(Environment.DIRECTORY_MOVIES);
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);
}

}


public void check_folder(String path)
{
File file=new File(path);

if(!file.exists())
{
file.mkdir();
}
}

关于java - 将电影文件保存在特定文件夹中 -android-,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43434201/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com