system.pathForFile returns nil

Hi,

This code works in the simulator but not on my Android device:

local path = system.pathForFile("chinese\_rules.db") print("PATH:: " .. tostring( path ) )

When I run this code on my Galaxy S4 path returns nil.

My first thought was that it was some type (case sensitivity) but I  can’t find any typo:

wlpu14.png

I can’t find any reason why it should receive nil. This causes a problem as I can’t load my database.

I have also tried this with the same result:

local path = system.pathForFile("chinese\_rules.db", system.ResourceDirectory)

I have been able to load a path and load databases like this before.

Corona Build: 2013.2100 (2013.12.7)

Best regards,

Tomas

Further reading the documentation I don’t see that .db is a restricted file type:

Corona allows direct loading of images and audio files using the appropriate APIs, but it has limited access to resource files on Android using the file I/O APIs. Specifically, the following types can not be read from the resources directory: .html, .htm., .3gp, .m4v, .mp4,.png, .jpg, and .ttf.

I think it would be best to try and do some general troubleshooting around things like :

  • Is there something about .db files that the Samsung does not like? Test this by trying to load a completely different but much simplar .db file.

  • Maybe there’s something about that specific call ‘system.pathForFile’, perhaps an alternative needs to be used.

  • Maybe try it on another person’s device. Perhaps it is something to do with Corona software combined with some kind of setting on your device?

I’m not sure really, just a few suggestions.

Thanks

Hi Sabir,

thanks for your tips.

I found out the reason for the problem:

We are to that are working on this project and he had setup to use expansion files so two files was created (the main APK and the OBB expansion file) which I didn’t notice and I only loaded the main APK file and I guess the database is in the OBB file. After setting not to use an expansion file the app works.

usesExpansionFile = false

Best regards,

Tomas

Further reading the documentation I don’t see that .db is a restricted file type:

Corona allows direct loading of images and audio files using the appropriate APIs, but it has limited access to resource files on Android using the file I/O APIs. Specifically, the following types can not be read from the resources directory: .html, .htm., .3gp, .m4v, .mp4,.png, .jpg, and .ttf.

I think it would be best to try and do some general troubleshooting around things like :

  • Is there something about .db files that the Samsung does not like? Test this by trying to load a completely different but much simplar .db file.

  • Maybe there’s something about that specific call ‘system.pathForFile’, perhaps an alternative needs to be used.

  • Maybe try it on another person’s device. Perhaps it is something to do with Corona software combined with some kind of setting on your device?

I’m not sure really, just a few suggestions.

Thanks

Hi Sabir,

thanks for your tips.

I found out the reason for the problem:

We are to that are working on this project and he had setup to use expansion files so two files was created (the main APK and the OBB expansion file) which I didn’t notice and I only loaded the main APK file and I guess the database is in the OBB file. After setting not to use an expansion file the app works.

usesExpansionFile = false

Best regards,

Tomas