appcelerator retrieve all files from directory
im working on an Ipad paint application and i want to retrieve all files from a specific directory, and delete the last saved image. In the appcelerator simulator it all works perfect, but when i run my application on my ipad it stops at var fid = dfo.getDirectoryListing(); I don't know what i'm doing wrong because i know he saves the png files in the test folder on ipad (tested it with alert).
//going to the folder, this works he shows alert
var dfo = Titanium.Filesystem.getFile(Titanium.Filesystem.resourcesDirectory + '/test');
alert(dfo);
//trying to get all the files, this works on emulator he shows all files. on ipad empty alert
var fi开发者_开发问答d = dfo.getDirectoryListing();
alert(fid);
//application stops here
fid = fid.splice(1, fid.length - 1);
alert(fid);
var lengte = fid.length - 1;
if (lengte != -1) {
var lengte2 = lengte -1;
painter.clear();
painter.setBackgroundImage(parent + '/back.png');
painter.setBackgroundImage(parent + '/test/' + fid[lengte2]);
var file = Titanium.Filesystem.getFile(parent + '/test/' + fid[lengte]);
file.deleteFile();
}
else{
alert('going back is at his end');
painter.clear();
painter.setBackgroundImage(parent + '/back.png');
}
I hope someone can help me, thanks in advance!
you should be saving your files to Ti.Filesystem.applicationDataDirectory not the resources directory.
I think the emulator is allowing it, but the device is not for security reasons..
精彩评论