34

How can I open an HTML file I have copied from PC to SD Card of Phone?

I've tried opening it with the default application which is HTML Viewer but I get a "Web page not available" system page. The URL that the browser shows is:

content://com.android.htmlfileprovider/mnt/sdcard/Documents/To%20Read.html?text/html

Any ideas?

Thanks.

2

7 Answers 7

21

You should be able to point the browser at the file you want with a URL of the format file:///path/to/file.html. For example, I just did this on my EVO with a file I saved to the root of my SD card as post.html by launching the browser and entering the URL file:///sdcard/post.html.

Alternatively, my file manager lets me open an HTML file with "HTML Viewer". This is not as feature-rich, though, and didn't seem to render images for me (whereas the browser way loaded everything properly). My file manager does not give me the option to open the file with the browser, or either of the other browsers I have (Firefox and Opera Mobile).

4
  • Excellent, thank you! It seems to work with just file:// (only 2 forward slashes) as well. Also, you are right, it's HTMLViewer software that opens it from the file browser app, not the real browser. Android should give you the option to open HTML files and such using any installed browser, hopefully in the future.
    – Francisc
    Jan 16, 2011 at 19:09
  • I am trying the same with opera.It is asking me not able to connect, check network settings. :( Sep 23, 2011 at 11:13
  • I had to file://mnt/sdcard/ and it showed Chrome's internal file explorer. Bookmark it to use. Homescreen shortcut wouldn't work.
    – Q20
    Oct 9, 2016 at 12:31
  • What about internal storage? What path to use then? Feb 3, 2017 at 11:04
3

Just type file://localhost/

It works in Opera Mobile.

1
  • Doesn't work for me but file://localhost/mnt/sdcard/ does on Opera version 30.0.1856 (24 Jun 2015) (don't confuse with Opera Mini which can't open local files). Found that it's very convenient to open such files with ES File Explorer: long tap on file -> More -> Open As -> Text -> Opera Aug 10, 2015 at 14:18
3

If your file is at /mnt/sdcard/test/file.html you can access it through the browser from using:

content://com.android.htmlfileprovider/sdcard/test/file.html

Note:

Your file location should not contain any spaces i.e. /mnt/sdcard/test location/file.html doesn't work, even if the URL replaces it with %20.

Additionally, bookmarking the URL helps!

1
  • 3
    The content:// URL just redirects me to a google search.
    – Jack M
    Oct 21, 2013 at 10:37
2

A few people allude to the issue of having spaces in the file name. I will clarify.

Android is based on Linux, and therefore uses a posix file system. This means that file names with spaces cause issues. Don't use spaces if you are creating a file or directory; leave them out or use periods (.), dashes (-), or underscores (_). To load an existing file with space in it, you must quote the file.

Using the example from the question replace:

content://com.android.htmlfileprovider/mnt/sdcard/Documents/To%20Read.html?text/html

with this:

content://com.android.htmlfileprovider/mnt/sdcard/Documents/"To Read.html"?text/html

If you are otherwise simply opening a file, you may quote the whole string. Like this:

"/mnt/sdcard/Documents/To Read.html"

In addition to spaces which can cause problems, posix systems permit characters in file names that are not permitted in Windows. To avoid issues when copying files between systems, even though some are still permitted on Windows as well, do not include the following characters in file names: / \ ? * : % " < > | + # '

To avoid further problems use a consistent style of capitalization in file names. Note that posix systems are case sensitive, which means file names are case sensitive. This means that file.txt, FILE.TXT, file.TXT, File.txt, georgE.txt, etc. are all different files on a posix system, while they are considered the same file on Windows.

1

On my Droid 4 (ICS) from VERIZON I get the browser's address box and type:

/mnt/sdcard-ext/my_page/index.html

Then set it as a bookmark. I use Chrome, not sure if I can set it as a home page like on my PC. This is on my SD card in a folder with lotsa pix.

To hide the pix from cluttering up your gallery, give the directory a period in front of it like /.my_page/. Use root explorer or a terminal emulator to check the location.

I think mnt/sdcard/ may point to device internal storage.

1
  • 1
    instead of hiding the directory (naming it .my_page), you can simply put an empty file named .nomedia into the directory -- with the advantage to easier find your directory (as it is not hidden), while still not "cluttering up your gallery". Media scanner skips all directories having this file inside.
    – Izzy
    Aug 31, 2012 at 11:23
1

Download the Android App from here - Google Play Store - OpenHTML

2
  • 1
    Can you elaborate a bit?
    – ale
    Feb 2, 2013 at 16:22
  • Simple and elegant solution.
    – Juanin
    Oct 9, 2013 at 20:51
0

Just rename the file by appendinh ".html" to it. For example, if the file name is "abcd", rename it to abcd.hmtl. This works for me in android 2.3.

You must log in to answer this question.

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