title: How to download and store pdf file in a folder in Android 10?
body: <p>Until Android pie my code was working fine. But when I update to Android 10, it shows following errors. How to sort it out?</p>
  
  <blockquote>
  <pre><code>E/SubsamplingScaleImageView: Failed to initialise bitmap decoder
      java.io.FileNotFoundException: open failed: ENOENT (No such file or directory)
          at android.os.ParcelFileDescriptor.openInternal(ParcelFileDescriptor.java:315)
          at android.os.ParcelFileDescriptor.open(ParcelFileDescriptor.java:220)
          at com.pdfview.PDFRegionDecoder.init(PDFRegionDecoder.kt:25)
          at com.pdfview.subsamplincscaleimageview.SubsamplingScaleImageView$TilesInitTask.doInBackground(SubsamplingScaleImageView.java:1564)
          at com.pdfview.subsamplincscaleimageview.SubsamplingScaleImageView$TilesInitTask.doInBackground(SubsamplingScaleImageView.java:1539)
          at android.os.AsyncTask$3.call(AsyncTask.java:378)
          at java.util.concurrent.FutureTask.run(FutureTask.java:266)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
          at java.lang.Thread.run(Thread.java:919)
  </code></pre>
  </blockquote>
  
  <p>I am Using following code.</p>
  
  <pre><code>URL url = new URL(aurl[0]);
  URLConnection conexion = url.openConnection();
  conexion.connect();
  
  int lenghtOfFile = conexion.getContentLength();
  String extStorageDirectory = Environment.getExternalStorageDirectory().toString();
  File folder = new File(extStorageDirectory, "tmf");
  folder.mkdir();
  
  InputStream input = new BufferedInputStream(url.openStream());
  OutputStream output = new FileOutputStream(folder + "/contract.pdf");
  
  byte data[] = new byte[1024];
  
  long total = 0;
  
  while ((count = input.read(data)) != -1) {
      total += count;
      publishProgress(""+(int)((total*100)/lenghtOfFile));
      output.write(data, 0, count);
  }
  
  output.flush();
  output.close();
  input.close();`
  </code></pre>