Create a File:
Creates a empty new file in a specified location that is relative to the directory.
"File createFile(DOMString relativeFilePath);"
Example:
tizen.filesystem.resolve(
<absolute path>,
function(dir){
dir.createFile(<filename>);
}, function(e) {
console.log("Error" + e.message);
}, "rw"
);
Writing to a File:
Writes the specified DOMString to a FileStream.
"void write(DOMString stringData);"
Example:
tizen.filesystem.resolve(
<filename with absolute path>,
function(fd){
var filehandler=fd;
fd.openStream(
"w",
function(fs){
fs.write(<data>);
fs.close();
}, function(e) {
console.log("Error " + e.message);
}, "UTF-8"
);
}, function(e) {
console.log("Error" + e.message);
}, "w"
);
Reading From a File:
Reads the specified number of characters from the position of the file pointer in a FileStream and returns the characters as a string. The resulting string length might be shorter than charCount if EOF is true.
"DOMString read(long charCount);"
Example:
tizen.filesystem.resolve(
<filename with absolute path>,
function(fd){
var filehandler=fd;
fd.openStream(
"r",
function(fs){
var data = fs.read(filehandler.fileSize);
fs.close();
}, function(e) {
console.log("Error " + e.message);
}, "UTF-8"
);
}, function(e) {
console.log("Error" + e.message);
}, "r"
);
For all the above operations Privilege has to be set in the config file:
Go to Config File > Privilege > and ADD the following privileges
http://tizen.org/privilege/filesystem.read and
http://tizen.org/privilege/filesystem.write
For more info please refer to: FileSystem API