Reputation: 197
i am trying to create a file in my worklight project using cordova File API. I am getting the error,
Reference Error: LocalFileSystem not defined
I tried using the solution in the following link but still i get the same error. Should i add any script files in my js folder? i am not sure where to get the exact cordova.js file from. PhoneGap- Android FileSystem Requesting Error
When i included the cordova.js file , i am getting the error
here is my code:
document.addEventListener("ondeviceready", onDeviceReady(), true);
function onDeviceReady() {
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onFileSystemSuccess, fail);
}
function onFileSystemSuccess(fileSystem) {
alert(fileSystem.name+" created");
alert(fileSystem.root.name);
}
function fail(evt) {
alert(evt.target.error.code);
}
}
Upvotes: 2
Views: 2930
Reputation: 3499
maybe you didn't install the file system plugin, try after cordova plugin add org.apache.cordova.file command.
Upvotes: 0
Reputation: 1043
document.addEventListener("ondeviceready", onDeviceReady(), true);
This is wrong. It means you put the return of that function as the argument. You just need to put the name of the function. Use this instead. (without () )
document.addEventListener("ondeviceready", onDeviceReady, true);
Upvotes: 1