title: How to correctly set the Uri of an image from a folder selected by the user to show in an ImageView?
body: <p>I need to display an image which I know the file name but I don't know the folder, which must be specified by the user.</p>
  
  <p>I use <code>Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);</code> to get the folder from the user. It returns an Uri with a path along these lines:</p>
  
  <blockquote>
    <p>content://com.android.externalstorage.documents/tree/primary%3ADownload</p>
  </blockquote>
  
  <p>Now I need to display an image from this folder in an ImageView. I tried the following:</p>
  
  <pre><code>Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), 
  Uri.parse(chosenFolder + "/image.png"));
  ImageView imageView = findViewById(R.id.imageview);
  imageView.setImageBitmap(bitmap);
  </code></pre>
  
  <p>The first line throws the following exception:</p>
  
  <blockquote>
    <p>java.lang.IllegalArgumentException: Invalid URI: content://com.android.externalstorage.documents/tree/primary%3ADownload/image.png</p>
  </blockquote>
  
  <p>Replacing <code>%3A</code> by <code>:</code> doesn't work.</p>
  
  <p>How to correctly set the Uri to display the image?</p>