【发布时间】:2015-01-04 07:56:54
【问题描述】:
我使用 DownloadManager 类在 android 中下载文件
这是我的下载代码:
Uri downloadUri = Uri.parse(urlString);
DownloadManager.Request request = new
DownloadManager.Request(downloadUri);
request.setDescription(des).setTitle(titleAudio).setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED).
setDestinationInExternalPublicDir(
"/my file name/" , titleAudio + String.valueOf(colForUrl) + pasvand);
long id = downloadManager.enqueue(request);
SharedPreferences.Editor prefEdit = preferenceManager.edit();
prefEdit.putLong(strPref_Download_ID, id);
prefEdit.commit();
但是当我在某些设备(Samsung Galaxy S5)上运行应用程序时,我收到了这个错误:
java.lang.IllegalStateException: Unable to create directory: /storage/emulated/0/my file name
这是在 setDestinationInExternalPublicDir(..)
但在 Nexus 7 中,一切都是正确的,我没有任何问题!!
那么,我哪里错了?!
【问题讨论】:
标签: android android-file android-download-manager android-internet