system.pathForFile returns nil on android for base dir

Hi All, 

i am trying to traverse a directory to get how many files are there, so i am doing a for loop 

first:

local doc_path = system.pathForFile( nil,system.ResourceDirectory)

for file in lfs.dir(doc_path … “/assets/images” ) do

but the problem i am having is that doc_path is nil on android. It works on the simulator and on iOS, but not on android.

Is there something that i am missing?

Thanks!

Android doesn’t have a real system.ResourceDirectory.  It’s all part of a big zip file that happens to be named .apk.  Corona extracts out files it needs when you tell it to access a file from system.ResourceDirectory.  But you are not asking for a file.  In other words, what you’re trying to do won’t work on Android. 

Since the files in your app’s system.ResourceDirectory is fixed and cannot be changed from the time you deploy the app, you should know when you build the app what files are there.  There isn’t much of a reason to need to traverse your read-only app bundle.  Build a list of the files and put them in a text file or something like that.

Rob

Android doesn’t have a real system.ResourceDirectory.  It’s all part of a big zip file that happens to be named .apk.  Corona extracts out files it needs when you tell it to access a file from system.ResourceDirectory.  But you are not asking for a file.  In other words, what you’re trying to do won’t work on Android. 

Since the files in your app’s system.ResourceDirectory is fixed and cannot be changed from the time you deploy the app, you should know when you build the app what files are there.  There isn’t much of a reason to need to traverse your read-only app bundle.  Build a list of the files and put them in a text file or something like that.

Rob