6

There are other questions on this same topic, but I'm finding that on 4.0.4 with my HTC One, I can open file:/// URLs just fine with Firefox, but not with Chrome or the Android browser. Those two simply report a security error and show no content.

Is this something that changed since the 2.x era when it was apparently possible? (edit well I realize there was no Chrome for 2.x but ...)

edit — sorry; false alarm. It works fine.

All the visible directories on the phone - those you browse through with a file explorer, or when you mount the device as mass storage - are under a top-level directory called "sdcard". Thus, if you create a folder at (apparently) the top level, then a file in it must be accessed as:

file:///sdcard/your_folder/hello_world.html

Probably most people know that already :-)

  • On 4.2.1 the URLs work fine on Chrome and Chrome Beta, but not the builtin browser. – onik Mar 4 '13 at 19:28
  • Hmm let me try my Nexus 7 - thanks for the info. – Pointy Mar 4 '13 at 19:35
  • Possibly it is disallowed to prevent hijacking? – t0mm13b Mar 4 '13 at 19:39
  • Actually I'm just dumb; I'll provide the "answer". – Pointy Mar 4 '13 at 21:18
  • 1
    @Pointy You should write the solution as an answer and accept it as soon as the time period for accepting your own answer is allows it. – onik Mar 5 '13 at 13:19
3

As I wrote in an addendum to my question, the issue was user error stemming from the less-than-obvious way the Android OS file system works. Everything visible in the file system is under a top-level (the real top) directory called "sdcard". Thus, file:/// URLs only work for paths like file:///sdcard/foo/bar.

I'll add with questionable relevance that if you haven't installed the app "AirDroid", you should. I found it while looking around for answers to a related problem.

| improve this answer | |
  • I get: "Access to the file was denied" for the extSdCard. – Luis A. Florit Feb 12 '16 at 18:20
  • what path must one use for internal storage?? – Fedor Steeman Feb 3 '17 at 10:58
  • @FedorSteeman it's in the answer above. – Pointy Feb 3 '17 at 13:28
  • thanks. I was getting confused over the fact that my unit didn't have an sd card, so it didn't make sense to me to go to the "sdcard". – Fedor Steeman Feb 3 '17 at 14:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.