I am using the Download Manager and when I use
setDestinationInExternalFilesDir(this, Environment.DIRECTORY_DOWNLOADS, "example.ext");
the files are downloaded to Android/data/com.example.app/files/Download folder.
When I try
setDestinationInExternalPublicDir("/folder", "example.ext");
I get:
IllegalStateException: Cannot create directory mnt/sdcard/folder
.
I've set the WRITE_EXTERNAL_STORAGE permission too.
What am I doing wrong?
Why don't you use absolute
path for ExternalFileDir
File sdCard = Environment.getExternalStorageDirectory();
String folder = sdCard.getAbsolutePath() + "/YourFolder" ;
File dir = new File(folder );
if (!dir.exists()) {
if (dir.mkdirs()) {
Log.i(Tag,"Directory Created");
}
}
I guess this might even work for you.