How to Read file from www directory?


#1

Hello, I have included a file info.json in www directory. I am trying to read it with the FileSystem but it gives me two types of error:

var f = 'file:///android_asset/www/info.json';
resolveLocalFileSystemURL(f, null, errorHandler); // I get Error: NOT_FOUND_ERR

If I check the resources tab in the chrome inspector the URL shows ‘file:///android_asset/www/info.json’

I also tried to request a FileSystem and then tried to getFile, I get a different error

window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fs){FS = fs}, errorHandler);
FS.root.getFile(‘file:///android_asset/www/info.json’, null, function(e){Entry=e}, errorHandler) // Error: 5 ENCODING

How should I do to locate and read the file?


#2

Hey there,

you could also use $http-Service to resolve the file.
And i think your second try goes in the right direction.

Could you post the content of the json file?

greetz, bengtler


#3

Hi I would like to ask another question. Consider that i have a folder File.checkDir(cordova.file.externalRootDirectory, “My Folder”). It has 10 audio file created by media plugin, each audio file has a random string as a file name with extension as .3gp, inside My Folder i need to get the list of all file name inside that folder could someone help me