1

Using JavaScript (not native code), is it possible to read folders and files from the www folder where, for example, phonegap.js is?

I've managed to read file contents with AJAX calls, but I'd like to know if there is a different way. Besides, you can't read folders like that.

From what I've seen, the File and FileEntry APIs that PG exposes only work on Persistent or Temporary locations on disk. I can't seem to be able to specify any location I want.

So, is there a way to do that with JS?

tshepang
  • 12,111
  • 21
  • 91
  • 136
Francisc
  • 77,430
  • 63
  • 180
  • 276

2 Answers2

1

No you can't do it with the FileReader as it can only read from the file system. For files in your app they are not actually on the file system and you will need to use XHR to read them.

However, I recently wrote a XhrFileReader interface to allow you to use the typical FileReader methods but still read files packaged with your app.

http://simonmacdonald.blogspot.ca/2013/02/phonegap-android-xhrfilereader.html

Simon MacDonald
  • 23,253
  • 5
  • 58
  • 74
0

You might be looking for the 'FileReader' object.

opznhaarlems
  • 337
  • 2
  • 9
  • In order to use FileRead, you need FileEntry and File, which, as I wrote in the question, cannot look outside the two preset folders as far as I could find. LocalFileSystem.PERSISTENT and LocalFileSystem.TEMPORARY being the two preset folders. – Francisc Feb 27 '13 at 09:26