Code works in simulator but not on device

I’m trying to run this code on my android device but it doesn’t seem to work.

local doc\_path = system.pathForFile(system.ResourceDirectory) .. directory for file in lfs.dir(doc\_path) do --Do something end

system.pathForFile returns nil on my device and if I remove it and then just use directory I get 
 

“cannot open /images/myprofile/avatars/”

I’ve also tried removing the begining slash and same thing 

“cannot open images/myprofile/avatars/”

I’m just trying to loop though a folder inside the apk. Is this not possible? 

Try GGFile and if that works for you, you can use it directly or tear out the code you need: https://github.com/GlitchGames/GGFile

not on android - it’s not a real directory.  easiest solve is to just pre-list these things into your build (using a .txt, or .xml, or even directly into a .lua) and iterate that instead of file system.  since you’re implying static content (ie, stuff built into your apk) there shouldn’t be any need to iterate the file system dynamically at run-time.

That is possible but the only issue is I was hoping to just be able to drop files into the directory and have the code do the rest for me. I plan to use this code in the future and wanted it to be easily portable from one app to another. If building a table of files is the only way then I guess that’s the way it will have to be.

I will give that a shot

Try GGFile and if that works for you, you can use it directly or tear out the code you need: https://github.com/GlitchGames/GGFile

not on android - it’s not a real directory.  easiest solve is to just pre-list these things into your build (using a .txt, or .xml, or even directly into a .lua) and iterate that instead of file system.  since you’re implying static content (ie, stuff built into your apk) there shouldn’t be any need to iterate the file system dynamically at run-time.

That is possible but the only issue is I was hoping to just be able to drop files into the directory and have the code do the rest for me. I plan to use this code in the future and wanted it to be easily portable from one app to another. If building a table of files is the only way then I guess that’s the way it will have to be.

I will give that a shot