Home > database >  Auto load subtitles without MANAGE_EXTERNAL_STORAGE permission on Android 11
Auto load subtitles without MANAGE_EXTERNAL_STORAGE permission on Android 11

Time:12-15

Is it possible to detect a subtitles file within the same folder as a video and load it without the user having to select subtitles files manually for each video?

CodePudding user response:

You can require access to directory instead of a single file:

https://developer.android.com/training/data-storage/shared/documents-files#grant-access-directory

With some restrictions:

On Android 11 (API level 30) and higher, you cannot use the ACTION_OPEN_DOCUMENT_TREE intent action to request access to the following directories:

  • The root directory of the internal storage volume.
  • The root directory of each SD card volume that the device manufacturer considers to be reliable, regardless of whether the card is emulated or removable. A reliable volume is one that an app can successfully access most of the time.
  • The Download directory.

Furthermore, on Android 11 (API level 30) and higher, you cannot use the ACTION_OPEN_DOCUMENT_TREE intent action to request that the user select individual files from the following directories:

  • The Android/data/ directory and all subdirectories.
  • The Android/obb/ directory and all subdirectories.

Source: https://developer.android.com/training/data-storage/shared/documents-files#document-tree-access-restrictions

  • Related