0

For some reasons, I am producing some HTML files from Terminal IDE. However, I can't seem to open any of them located in the working directory. Say we have

/data/data/com.spartacusrex.spartacuside/files/index.html

Firefox shows nothing after I enter the URL

file:///data/data/com.spartacusrex.spartacuside/files/index.html

And Chrome complains 'Access denied'.

I don't want to root the device. Any walkaround?

0

2 Answers 2

0

Application data is sandboxed on Android. Apps can only access their data directory, they cannot access the data of other applications. This is why your browsers cannot access the files that are located in Terminal IDE's directory.

Even with root, you will not be able to access those files the way you are attempting to. Your browsers are not programmed to request or use root permissions. Simply rooting your device will not suddenly grant them access to your entire filesystem. You would incur an additional step: you would need to try to modify the permissions of the files before opening them with the browser.

You need to move the files to a storage location that other apps can read, like a folder on your "external" storage (either a physical SD card or a virtual one like /data/media). Accessing them directly via your browser while they reside in the Terminal IDE directory is impossible without root.

0

Here's a work-around that seems to work on my (non-rooted) Android device. Does it work for you?

At the Spartacus Rex Terminal IDE command prompt, type

cd ~/sdcard ;
vim a.html

then enter a quick JavaScript program:

<script>
document.write( "hello." );
alert("hi!");
</script>

Then press the ESC button and ":wq" to save the program and quit back to the command prompt.

Hit the Home button and fire up your favorite web browser, and use this URL:

file://sdcard/sdcard/a.html

You should see the "hi" alert pop up on top of a page saying "hello.".

(I originally posted something like this to https://en.wikibooks.org/wiki/Android/Terminal_IDE ).

2
  • Shouldn't the URL be file:///sdcard/a.html? I'm missing something here. Would you mind mentioning the HOME directory for Terminal IDE? You've referenced it with ~. Standard mksh has /data as the home directory.
    – Firelord
    Commented Jan 16, 2016 at 4:36
  • Both "file://sdcard/sdcard/a.html" and "file:///sdcard/a.html" correctly show the same file in my favorite Android web browser. On my device, typing "cd ~ ; pwd" at the Terminal IDE command line tells me "/data/data/com.spartacusrex.spartacuside/files", but I don't see how that's relevant. In that directory, "sdcard" is a soft link to "/storage/emulated/0".
    – David Cary
    Commented Jan 16, 2016 at 6:22

You must log in to answer this question.

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