0
votes

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 typo (case sensitivity) but I can't find any typo: http://i59.tinypic.com/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)

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.

http://docs.coronalabs.com/api/library/system/pathForFile.html

1

1 Answers

0
votes

I found out the reason for the problem: We are two 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