Android: allow browser to read file:///sdcard

2.2k Views Asked by At

On Android versions higher than v4.4 (since storage framework was introduced) opening the local memory filesystem in a web browser via file:///sdcard does not show all the files and folders.

For example, I can access the file:///sdcard/Download folder by typing the URL but some files and folders are not shown or some folders cannot be navigated to.

Tried with different browsers, including Firefox, Chrome, Chromium, Brave and Opera, and even though I've given all the apps the Files and media permission this is observable for all of them. Files downloaded by a specific browser would be visible from that browser, but not other files that have been placed there by other apps.

The question is how to grant full file access to /sdcard or a specific subfolder from outside the app since not all browsers mentioned above can trigger the on-demand storage permission dialog. Opera is the only browser which seems to allow doing it from within the app when saving a file to a custom path — then it triggers the on-demand permission dialog and as a side effect, the chosen folder becomes fully accessible through the file:// protocol.

The preferred solution would be via adb with pm or something similar.

1

There are 1 best solutions below

0
ccpizza On

While something like appops might allegedly be used to achieve the desired goal as per this article (didn't work for me), an easier workaround is to use the App Manager (f-droid) and enable in the App Ops tab the following permissions for your browser app:

  • MANAGE_EXTERNAL_STORAGE
  • LEGACY_STORAGE
  • NO_ISOLATED_STORAGE

After applying these actions for Brave, Chrome, and Chromium started displaying all files.

NOTE: Only tried on a rooted device. Since I have no unrooted devices at hand I cannot tell if this would also work on stock Android.