title: How to use Intent.ACTION_OPEN_DOCUMENT in Android Pie
body: <p>I'm making a profile photo change function using Retrofit in android pie.</p>
  
  <p>So I succeeded in uploading the photos taken with the camera to the server.
  But I don't know how to transfer the photos selected from the gallery to my server.
  (I'm fine with any kind of code in Java Kotlin.)</p>
  
  <p><em>I will upload the video later.</em></p>
  
  <p>I searched a lot on Google, but it was hard to get the information I wanted.</p>
  
  <p>Well done in the google doc but i don't know how to do it.
  <a href="https://developer.android.com/guide/topics/providers/document-provider" rel="noreferrer">https://developer.android.com/guide/topics/providers/document-provider</a></p>
  
  <p>The Google doc shows examples of using bitmap or inputstream or something.</p>
  
  <p>Do I need a bitmap or inputstream to upload photos using Retrofit?</p>
  
  <p>I actually need a valid uri.</p>
  
  <pre><code>public void performFileSearch() {
          Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
          intent.addCategory(Intent.CATEGORY_OPENABLE);
          intent.setType("image/*");
          startActivityForResult(intent, PICTURES_DIR_ACCESS_REQUEST_CODE);
  }
  
  
  @Override
  public void onActivityResult(int requestCode, int resultCode,Intent resultData) {
      if (requestCode == READ_REQUEST_CODE &amp;&amp; resultCode ==Activity.RESULT_OK) {
          Uri uri = null;
          if (resultData != null) {
              uri = resultData.getData();
              Log.i(TAG, "Uri: " + uri.toString());
              showImage(uri);
          }
      }
  }
  
  
  public void Edit_Profile (String Image_Uri) {
      File file = new File(Image_Uri);
      RequestBody requestBody = RequestBody.create(file, MediaType.parse("image/*"));
  
      MultipartBody.Part body = MultipartBody.Part.createFormData("uploaded_file", Num+ID+".jpg", requestBody);
  }
  </code></pre>
  
  <p>In fact, onActivityResult returns the following type of uri.</p>
  
  <pre><code>content://com.android.providers.media.documents/document/image%3A191474
  </code></pre>
  
  <p>So when I try to send it to my server using that uri I get a FileNotFoundException error.</p>