I am trying to follow the example that is provided on PhoneGap’s documentation, except instead of calling the window.requestFileSystem… inside the onDeviceReady, I am calling that whenever I actually need to access a certain file. For some reason, my code does not seem to go past that line.
function pullSelectRecord(link)
{
selectedFile = link;
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
}
function gotFS(fileSystem) {
alert("this is" + selectedFile);
fileSystem.root.getFile(link, null, gotFileEntry, fail);
}
function gotFileEntry(fileEntry) {
fileEntry.file(gotFile, fail);
}
function gotFile(file){
readDataUrl(file);
readAsText(file);
}
function readAsText(file) {
var reader = new FileReader();
reader.onloadend = function(evt) {
alert(evt.target.result);
};
reader.readAsText(file);
}
You can call requestFileSystem from anywhere. If you are not getting past that line you’ll need to look in “adb logcat” to see what the error could be. Also, make sure your Manifest.xml has the write external storage permission.