I use DownloadManager class to download a file in android
and this is my code for download:
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();
but when I run app in some device(Samsung Galaxy S5) I get this error:
java.lang.IllegalStateException: Unable to create directory: /storage/emulated/0/my file name
and this is caused in setDestinationInExternalPublicDir(..)
but in Nexus 7 every thing is right , I have not any problem!!
So, Where is my wrong?!