How to open local file from Tide SDK app

by THavamani 2013-04-29 15:28:13



we can access local file system in tidesdk application.


See the following code.

var contents;
var file= 'test.txt';
var Dir = Ti.Filesystem.getUserDirectory();
var readfi= Ti.Filesystem.getFile(Dir, file);
if (readfi.exists())
{
var Stream = Ti.Filesystem.getFileStream(readFi);
Stream.open(Ti.Filesystem.MODE_READ);
contents =Stream.read();
alert( contents );
Stream.close();
}

The above code will read the text file and alert the content. Visit here to know tidesdk file system.
409
like
0
dislike
0
mail
flag

You must LOGIN to add comments