title: Android 11 (30 API) File.listFiles() doesn't return all files
body: <p>So I tested 29 and 30 Android API devices. Both has Download folder with 5 files (equal for both devices).</p>
  <p>App has <code>&lt;uses-permission android:name=&quot;android.permission.READ_EXTERNAL_STORAGE&quot; /&gt;</code> in manifest and requests it in runtime.</p>
  <p>Also includes <code>android:requestLegacyExternalStorage=&quot;true&quot;</code> (which is only for Android 10, Android 11 ignores it)</p>
  <pre><code>private fun init() {
      val path = File(Environment.getExternalStorageDirectory(), &quot;Download&quot;)
      val files = path.listFiles()
      Timber.d(&quot;Android API ${Build.VERSION.SDK_INT}, dirFiles \n${files?.joinToString(separator = &quot;\n&quot;) { it.name }}&quot;)
  }
  </code></pre>
  <p>Android 11 (30 SDK):</p>
  <pre><code>2021-10-06 23:40:52.182 9022-9022/com.example.tests D/MainActivity: Android API 30, dirFiles 
      Elephants Dream.srt
      Elephants Dream.mkv
  </code></pre>
  <p>Android 10 (29 SDK):</p>
  <pre><code>2021-10-06 23:45:51.835 8293-8293/com.example.tests D/MainActivity: Android API 29, dirFiles 
      Elephants Dream.srt
      Elephants Dream.ssa
      Elephants Dream.vtt
      Elephants Dream.ass
      Elephants Dream.mkv
  </code></pre>
  <p>As you can see Android 11 doesn't return all files using <code>File.listFiles()</code> method.</p>
  <p>It filters files on system level by some Media filter. p.s. <code>MediaStore</code> cursor query returns same limited results</p>
  <p>It recognizes that <code>srt</code> format subtitles file is media type, but <code>ssa</code>, <code>vtt</code> or <code>ass</code> subtitles file aren't media!</p>
  <p>Quite weird logic. <code>ssa</code>, <code>vtt</code>, <code>ass</code> are also subtitles!</p>
  <p>For Android 10 READ or WRITE storage permissions looks like this in the settings:</p>
  <p><a href="https://i.stack.imgur.com/e7lE6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/e7lE6.png" alt="enter image description here" /></a></p>
  <p>For Android 11 READ or WRITE storage looks like this:</p>
  <p><a href="https://i.stack.imgur.com/AS2KV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AS2KV.png" alt="enter image description here" /></a></p>
  <p>I have an video player app which has to support many subtitles formats but I can only get <code>srt</code> on Android 11.</p>
  <p>How to get all needed files?</p>
  <p><strong>UPDATE</strong></p>
  <p>Seems the only way for Android 11 is <strong>Request All files access</strong> <a href="https://developer.android.com/training/data-storage/manage-all-files#all-files-access" rel="nofollow noreferrer">https://developer.android.com/training/data-storage/manage-all-files#all-files-access</a></p>
  <p>But it will be challenging to be approved by Google</p>
  <p>We could use SAF (Storage Access Framework) but it has many limitations for Android 11 <a href="https://developer.android.com/training/data-storage/shared/documents-files#document-tree-access-restrictions" rel="nofollow noreferrer">https://developer.android.com/training/data-storage/shared/documents-files#document-tree-access-restrictions</a></p>
  <p><a href="https://i.stack.imgur.com/lFxTL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lFxTL.png" alt="enter image description here" /></a></p>