title: Can not get file on android API 29 up
body: <p>I can not read a file that I'm saving. I have declared and asking for storage permissions.</p>
  <pre><code>fun saveImage(bitmap: Bitmap, context: Context): String {
      if (android.os.Build.VERSION.SDK_INT &gt;= 29) {
          val values = contentValues()
          values.put(MediaStore.Images.Media.RELATIVE_PATH, &quot;Pictures/&quot; + context.getString(R.string.app_name))
          values.put(MediaStore.Images.Media.IS_PENDING, true)
          // RELATIVE_PATH and IS_PENDING are introduced in API 29.
  
          val uri: Uri? = context.contentResolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values).also { uri -&gt;
              if (uri != null) {
  
  
                  if (uri != null) {
                      saveImageToStream(bitmap, context.contentResolver.openOutputStream(uri))
                      values.put(MediaStore.Images.Media.IS_PENDING, false)
                      context.contentResolver.update(uri, values, null, null)
  
                  }
  
  
                  //val split = file.path.split(&quot;:&quot;.toRegex()).toTypedArray() //split the path.
                  Log.d(
                      &quot;Tag&quot;,
                      &quot;v--- uri.path - ${uri.path}, &quot;
                  )
  
                  return uri.path.toString() //assign it to a string(your choice).
  
  
              }
          }
  
      } else { // below API 29 }
  }
  </code></pre>
  <p>then in onCreate or any other method I want to access that file and show on preview.</p>
  <pre><code>            val previousPath = &quot;&quot;&quot;/external/images/media/356&quot;&quot;&quot; //preferenceManager.getString(...)
              //val file  = File(path)
  
              //previewImage.setImageURI(Uri.parse(previousPath))
         val file  = FileUtils().getFile(applicationContext, Uri.parse(previousPath))
                              Log.d(&quot;Tag&quot;, &quot;Yo --- &quot;+file?.path + &quot; , &quot;+ file?.name)
  
  
  //  val myBitmap = BitmapFactory.decodeFile()
  // previewImage.setImageBitmap()
  </code></pre>
  <p>But this is always empty. With <a href="https://stackoverflow.com/a/65447195/7291498">this getFile method</a>, I get null pointer exception. I need the file to upload to server. How can I get this file?</p>