JavaScript
{dialog.object}phoneGapWriteFileURL Method
Syntax
{dialog.object}.phoneGapWriteFileURL(filepath, text, onWriteSuccess, onError, append);
Arguments
- filepath
The complete path and name of the file to write on the file system. Use the {dialog.object}.phoneGapGetLocalDirURL() method to get the base path of the file.
Use the {dialog.object}.phoneGapEnsureDirPathURL() method to ensure that the directory exists before writing the file.
- text
The data to write to the file.
- onWriteSuccess
A javascript function that is called once the file is written.
- onError
A javascript function that is called if an error occurs when trying to write the file.
- append
true or false. If true, text will be appended to the file. If false, the contents in the existing file will be overwritten.
Description
Write to a file.
Example
var onSuccess = function(result) { alert("Write was successful!"); }; var onError = function(e) { alert("An error occurred"); }; var filepath = {dialog.object}.phoneGapGetLocalDirURL('temp') + 'myfile.txt'; var data = 'Some text'; var append = false; {dialog.object}.phoneGapWriteFileURL(filepath, data, onSuccess,onError, append);
See Also