在此代码之后下载到sdCard,但我需要下载到exSdCard 我已尝试用
做到这一点.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, title+".flv");
但不起作用......它会下载到内部存储器
我也试过setDestinationInExternalFilesDir (context,Environment.DIRECTORY_DOWNLOADS, title+".flv");
但它下载到内部存储器 Android / data / com.example.app / files / Download 文件夹
:sdcard - 它是内部的 exSdCard它是http://content.answcdn.com/main/content/img/CDE/_COMPSD.JPG
public void file_download(String uRl,String title) {
File direct = new File(Environment.getExternalStorageDirectory()
+ "/Download/Videos");
if (!direct.exists()) {
direct.mkdirs();
}
DownloadManager mgr = (DownloadManager) activity.getSystemService(Context.DOWNLOAD_SERVICE);
Uri downloadUri = Uri.parse(uRl);
DownloadManager.Request request = new DownloadManager.Request(
downloadUri);
request .setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI|DownloadManager.Request.NETWORK_MOBILE)
.setAllowedOverRoaming(false).setTitle(title)
.setDescription("/Download/Videos/"+title)
.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, title+".flv");
mgr.enqueue(request);
}
答案 0 :(得分:0)
getExternalStorageDirectory
用于返回设备环境中设置为“外部存储”的内容。
它不是可移动媒体。而不是你只是尝试阅读isExternalStorageRemovable()
以检查它是否可移动,并getExternalStorageState()
来检查状态。有关详细信息http://developer.android.com/reference/android/os/Environment.html