write file
I would like to write a text file (.txt) , in which I use the following code:
var file1 = Titanium.Filesystem.getFile(Titanium.Filesystem.resourcesDirectory, 'test.txt');
var cont;
if (file1.exists()) {
cont = file1.read();
alert("File exists");
} else {
file1.write('Hello World...');
cont = file1.read();
Ti.API.info("File save");
alert("File1 : "+cont.text);
}
This code doesn't cause me any problem in the simulator, but when I put it in th Iphone it doesn't work.
Can somebody help me please?
1 Answer
-
I was pulling my hair out with the filesystem earlier this week. The simulator was giving me one thing and I couldn't tell what I was getting on my iPhone end.
In your code have an alert that pops up and telling you if the
var file1
is writable. This way you know for sure. I had to use the temp directory.