10

You may note the almost duplicate title from this question. It keeps coming up when trying to solve my current issue.

I created a little web app to help at work. Just some HTML and JavaScript, and before Android started enforcing the Scoped Storage, I had no issues using it. Now when I try to load the URL (ie: file:///storage/emulated/0/__MyDocs/SignInTracker.html) I get an access denied error.

I could use Firefox, but it seems to be because it's not yet using the Scoped Storage standard, which if I understand correctly, will be a requirement in the next Android version, so that means I cannot rely on it working in the future. Also, Firefox just doesn't run as nicely as Chrome.

Is there a proper way for a non-Android-developer to use a local web app like this? Is there perhaps a location on the phone where I can place my .html and .js files that will allow Chrome to access them without issues? At work, I'm not online or connected to anything, so loading from another server/computer is not an option.

For reference: My Chrome version is 79.0.3945.116, my Firefox version is 68.4.1, and my phone OS is Android 10; Pixel Build/QP1A.191005.007.A1.

1
  • This same problem occurs with other browsers like Firefox and Bromite :-(
    – Dimitri C.
    Commented Jul 16, 2023 at 19:52

4 Answers 4

10

You have 2 options:

  • You can use a local web server in your Android phone itself. There are many server apps out there in the Play Store, one such app is Simple HTTP Server.

  • You can put your documents into the folder Android/data/com.android.chrome/files/Download/ in the internal storage. It's absolute path is /storage/emulated/0/Android/data/com.android.chrome/files/Download/ or /sdcard/Android/data/com.android.chrome/files/Download/. This is the location where Chrome stores any downloaded files and therefore, this the only location where Chrome can access the files. But remember, uninstalling Chrome will delete this directory.

3
  • 1
    I had tried some server apps but they all had issues (one of them didn't even process Javascript). Placing the files in that directory seems to have worked though. Thanks!
    – therks
    Commented Jul 11, 2020 at 22:04
  • You can also use Opera browser of you wish. It is much similar to Chrome since both use the same engine. Opera have no issues at all while browsing the storage.
    – Puspam
    Commented Jul 17, 2020 at 19:29
  • Thanks a lot for the suggestion of Simple HTTP Server: it is very easy to use, is free and works like a charm. This is a very elegant workaround! Still I don't fully understand why Android doesn't allow to give apps access to selected folders in the local storage. Maybe in the future this will be implemented; let's hope.
    – Dimitri C.
    Commented Jul 16, 2023 at 19:55
6

For Android 11 [One UI 3.1]

Browsing local files (in internal storage space) in Chrome using file:///sdcard/ or file://localhost/sdcard/, one can notice that only media files and subdirectories (if any) are listed in almost every folder except the "Download" folder (but not in its subfolders=subdirs).

This means that on Android 11, the folder from which Chrome can read local (m)HTML is /Download folder, not Android/data/com.android.chrome/files/Download in internal or external storage space like in Android 10.

NOTE: on my Samsung devices, downloads onto internal storage were saved into /Download folder in all versions of Android (9, 10, 11), but downloads on an external SD card changed their folder from /storage/emulated/exSD_CARD/Android/data/com.android.chrome/files/Download in Android 10 to /storage/emulated/exSD_CARD/Download in Android 11, where exSD_CARD is the device's label for external SD card (0123-4567 or 9C33-6BBD in my devices)

Thus, (m)HTML files saved into /Download folder with Chrome (with .mhtml extension from older times or with manually added extension by renaming saved mhtml files without extension - from certain time Chrome stopped to append .mhtml extension to saved mhtml files :) on my devices, I guess from upgrading to Android 10)

This did not work for the mhtml files which have been moved to other folders and then returned to /Download folder. (And because of collecting saved mhtml files in many different folders, I have many mhtml files which are necessary to copy/move back to /Download folder prior to opening but they still cannot be opened)

Notes about opening mhtml files

I need to use Total Commander's "Open with" functionality with file://url option checked, then choose Chrome in order to open (mhtml) file with Chrome (with file://url checked, the Chrome is in the list to choose from, with file://url option unchecked, it is not listed in the list) or to browse local files in internal storage directly in Chrome (file manager My Files provided with the device was unusable to choose mhtml files to be opened with Chrome)

(mhtml) files from /Download folder opened in this way are opened as offline versions of downloaded web pages - but only if the file was not moved and returned back to /Download folder, otherwise you get Access Denied message. Also, opening (mhtml) files in this way using Total Commander, but from other folders than /Download folder, leads to Access Denied message

Opening mhtml files from any folder using Total Commander, but with file://url option unchecked (in this case, the Chrome is not in 1st list, so you need to choose "Open with *" option with folder icon from the list and subsequently choose Chrome from next list) behaves differently. Opening in such a way leads not to successful opening or Access Denied message but to Save as Dialog Form in which one can choose also if the resaved mhtml file should be saved to internal storage or external SD card (if present). In this way, resaved mhtml files in /Download folder (on internal or external storage space) can be now opened using Total Commander "Open with" dialog with checked file://url option.


Still, there exists a way of opening the (m)HTML files with Chrome

  • without other browsers/viewer
  • without rooting the Android device

but maybe only until the next update :)

1
  • Thank you! The URL file:///sdcard/ works on Android 8.
    – gearcoded
    Commented Aug 19, 2023 at 20:52
1

My workaround to open local files on my Samsung tablet is this:

  1. Install Ghost Commander from f-droid.org (link)

  2. Navigate to the directory where the .html file is, then double-click on it and open with Chrome, Opera, or Samsung web browser. Sadly I'm unable to associate with Firefox for Android (not listed).

The URL seems a bit random: content://com.ghostsq.commander.FileProvider/FS/L3N0c3JhZ2UvZW11bBF1ZWQvMC9Nb3ZpZXMvenNhbmk/videos.html

But everything works, all the relative paths listed in the .html are working.

In my case, I have a list of videos which I can filter from .css only (embedded inside the .html file) without any additional javascript.

-1

My Choice: Total Commander,

available on Google Play, also for All windows versions since ages (as far back as having a 16 bit Win 3.1 version downloadable).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .