ここで完全な例を見ることができます:
http://docs.phonegap.com/en/1.4.1/phonegap_file_file.md.html#FileWriter
この行は、ファイルが存在しない場合に作成します。
fileSystem.root.getFile("readme.txt", {create: true, exclusive: false}, gotFileEntry, fail);
サポートされているプラットフォーム
Android BlackBerry WebWorks (OS 5.0 以降) iOS Windows Phone 7 (Mango)
他の人については知りませんが、iOS ではドキュメントは /var/mobile/Application/YOU_APP/Documents に作成されます
[コード]
<script type="text/javascript" charset="utf-8">
// Wait for PhoneGap to load
//
document.addEventListener("deviceready", onDeviceReady, false);
// PhoneGap is ready
//
function onDeviceReady() {
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
}
function gotFS(fileSystem) {
fileSystem.root.getFile("readme.txt", {create: true}, gotFileEntry, fail);
}
function gotFileEntry(fileEntry) {
fileEntry.createWriter(gotFileWriter, fail);
}
function gotFileWriter(writer) {
writer.onwrite = function(evt) {
console.log("write success");
};
writer.write("some sample text");
writer.abort();
// contents of file now 'some different text'
}
function fail(error) {
console.log("error : "+error.code);
}
</script>
それが役に立てば幸い