title: Caused by: java.lang.IllegalStateException: Unable to create directory in Android 6.0 devices
body: <p>I have to store the download the image from the url using DownloadManager and store it into the sdcard with my own directory like "xyz". This is my code</p>
  
  <pre><code>File img_directory = null;
  
  img_directory = new File(Environment.getExternalStorageDirectory() + "/xyz");
  if (!img_directory.exists()) {
      img_directory.mkdirs();
      DownloadManager mgr = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
      Uri downloadUri = Uri.parse("my image url");
      DownloadManager.Request request = new DownloadManager.Request(downloadUri);
      request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI | DownloadManager.Request.NETWORK_MOBILE)
        .setAllowedOverRoaming(true)
        .setTitle("Demo")
        .setDescription("Something useful. No, really.")
        .setNotificationVisibility(DownloadManager.Request.VISIBILITY_HIDDEN);
        .setDestinationInExternalPublicDir(Environment.getExternalStorageDirectory().getAbsolutePath() + "/xyz", image.jpeg);
      mgr.enqueue(request);
  }
  </code></pre>
  
  <p>This code will run upto Android 5.1.1 . When I run this same code in 6.0 its raising the error like this </p>
  
  <pre><code>Caused by: java.lang.IllegalStateException: Unable to create directory: /storage/emulated/0/storage/emulated/0/xyz at android.app.DownloadManager$Request.setDestinationInExternalPublicDir(DownloadManager.java:538)
  </code></pre>
  
  <p>I have added the READ and WRITE permissions in manifest file. How can I resolve this error? Any body can help me ? Thanks in advance.</p>