getFile vs createFile
Pardon my noobishness … but I don't grasp the difference between .getFile and .createFile
the kitchen sink seems to use .getFile to create a file … but I can't make that work.
Can somebody tell me what's wrong here?
Basically, I'm just trying to see if a file exists … and create it if it doesn't.
var f = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory, 'fwb.txt');
if (f.exists()) {
label1.text = 'Welcome Back!';
} else {
label1.text = 'Hello, and welcome!';
f = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory, 'fwb.txt');
}
1 Answer
-
Accepted Answer
For me it works.
Maybe you need to write something to the file.label1.text = 'Hello, and welcome!'; f = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory, 'fwb.txt'); f.write('something');