0
我已經使用下面的代碼從android工作室的服務器下載視頻,它工作正常,但是當我在我的設備中搜索視頻時,我無法在任何地方找到它...它在哪裏保存以及如何更改目標目錄在「內部存儲」?如何將下載的文件保存到android的內部存儲中?
private DownloadManager downloadManager;
btn_download_video.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
downloadManager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
Uri uri = Uri.parse(urlVideo);
DownloadManager.Request request = new DownloadManager.Request(uri);
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.setDestinationInExternalFilesDir(Video_detail_Activity.this, Environment.DIRECTORY_DOWNLOADS, videoName);
Long reference = downloadManager.enqueue(request);
}
});
我用下面的權限在我的項目過於:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
你可以使用'setDestinationInExternalPublicDir()'或類似的'DownloadManager.Request'方法 – pskink
檢查下載文件夾 –