title: Android Open Assets Image File with Intent and FileProvider Shows Size 0
body: <p>I place all the files in <strong>assets</strong> folder and use following functions to open them:</p>
  <pre><code>fun Fragment.openAssetsFile(fileName: String) {
      val file = getAssetsFile(fileName)
      val fileUri = FileProvider.getUriForFile(requireContext(), &quot;${requireContext().packageName}.provider&quot;, file)
  
      val intent = Intent(Intent.ACTION_VIEW).apply {
          type = &quot;application/${file.extension}&quot;        //&lt;- doesn't work for image (jpg, png)
          data = fileUri
  
          addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
      }
  
      startActivity(intent)
  }
  
  fun Fragment.getAssetsFile(fileName: String): File {
      val file = File(requireContext().filesDir, fileName)
  
      if (!file.exists()) {
          file.outputStream().use { outputStream -&gt;
              requireContext().assets.open(fileName).use { inputStream -&gt;
                  inputStream.copyTo(outputStream)
              }
          }
      }
  
      return file
  }
  </code></pre>
  <p>Working perfectly fine with <strong>Word, Excel, PPT, PDF, Mp4, Mp3,</strong> but for <strong>JPG, PNG</strong> it shows 0 size like this:</p>
  <p><strong>(Had tried setting the mime type <code>image/*</code> but no help.)</strong></p>
  <p><a href="https://i.stack.imgur.com/Pjy6p.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Pjy6p.png" alt="enter image description here" /></a></p>
  <hr />
  <p><strong>Update:</strong> Tested on Samsung Tab S5e tablet, Samsung S22 Ultra, Huawei P50 Pro and Samsung Note 9, only the Note 9 has the issue.</p>