Hi, i'm trying to read a text file (a csv like file) located in a subfolder of the Resources folder in my appcelerator folder (it is located on Resources/quizzes/quizzes.qpak and as said is a simple text file with some separators, like csv).
I use the following code to get the file and read it:
var file = Titanium.Filesystem.getFile(packageFile) if(file.exists()) { var text = file.read().text; ....in iOS Simulator it works. But when i try it in Android emulator (2.3.3, V8) the file.exists() function returns false, so i think it is like the file is not found. Even if i comment the if(file.exists()) to avoid checking if the file exists the next code doesn't work (like if it can't find the file).
Can you give me some glue ? There are some differences on how iOS and Android project manages the files inside the Resources folder ?
Thanks!
3 Answers
For file access issues (more common when I need to download a file first) you can use DDMS to browse the emulator/device filessytem to ensure your file was actually copied over. On iOS you can browse the simulators directory structure looking for your files as well.
Now, to your code. Since we don't know what the value of packageFile is, its difficult to troubleshoot.
Take a look at Titanium.Filesystem.resourcesDirectory
packageFile = 'mydata.csv'; var file = Ti.FileSystem.getFile(Titanium.Filesystem.resourcesDirectory + packageFile);
Right, i've forgot to say what is the value of packageFile. It is "quizzes/indovinelli.qpak" and as said it works on iOS, so if appcelerator manages the paths the same way it should work also on android.
I'll try now seeing with DDMS and let you know.
Thanks in the meanwhile!
Just to be clear: the file indovinelli.qpak is inside Resources/quizzes/indovinelli.qpak in my project folder structure. (in the first question i said quizzes.qpak instead of indovinelli.qpak for simplicity, but the file is indovinelli.qpak).
Your Answer
Think you can help? Login to answer this question!