• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps [Cordova] Load file from Internal Storage

ptheg

Lurker
Oct 8, 2012
5
0
Hi,

is it possible to load a file with Cordova from the Internal Storage of an Android device, i.e. a file that is stored the following way:

Code:
FileOutputStream fos = openFileOutput(fileName, Context.MODE_PRIVATE);
fos.write(html.getBytes());
fos.close();

In JS I have tried to access the directory as follows:

Code:
var internalStorage = "file:///data/data/myproject/files/"; // also without file://
var dirEntry = new DirectoryEntry({fullPath:internalStorage});

But it doesn't work. I got the error message: "Uncaught ReferenceError: DirectoryEntry is not defined at file:///android_asset/www/index.html:12"

Using the path as a link works:
Code:
<a href="file:///data/data/myproject/files/storedFile.html">Go to stored file</a>

Is there a way to access the internal storage?

Thank you in advance.
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones