"readme.txt" not found. Phonegap example are not working on iphone and android
document.addEventListener("deviceready", onDeviceReady, false); function onDeviceReady() { window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail); } function gotF开发者_如何学编程S(fileSystem) { fileSystem.root.getFile("readme.txt", null, gotFileEntry, fail); } function gotFileEntry(fileEntry) { console.log(evt.target.error.code); } function fail(evt) { console.log(evt.target.error.code); }
You can only get file in the Document folder of the application.
If the file is not found you can create it by replacing 'null' with {create: true} in the getFile()
function like so
<script type="text/javascript" charset="utf-8">
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
}
function gotFS(fileSystem) {
fileSystem.root.getFile("readme.txt", {create: true}, gotFileEntry, fail);
}
function gotFileEntry(fileEntry) {
console.log("gotFileEntry");
}
function fail(evt) {
console.log("Error : "+evt.code);
}
</script>
精彩评论