简体   繁体   English

Corona SDK:system.pathForFile返回nil

[英]Corona SDK: system.pathForFile returns nil

This code works in the simulator but not on my Android device: 该代码可在模拟器中使用,但不能在我的Android设备上使用:

 local path = system.pathForFile("chinese_rules.db")
 print("PATH:: " .. tostring( path ) )

When I run this code on my Galaxy S4 path returns nil. 当我在Galaxy S4路径上运行此代码时,返回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 我的第一个想法是输入错误(区分大小写),但是我找不到任何输入错误: 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) 电晕版本:2013.2100(2013.12.7)

Further reading the documentation I don't see that .db is a restricted file type: 进一步阅读文档,我看不到.db是受限制的文件类型:

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. Corona允许使用适当的API直接加载图像和音频文件,但是使用文件I / O API限制了对Android上资源文件的访问。 Specifically, the following types can not be read from the resources directory: .html, .htm., .3gp, .m4v, .mp4,.png, .jpg, and .ttf. 具体来说,无法从资源目录中读取以下类型:.html,.htm。,。3gp,.m4v,.mp4,.png,.jpg和.ttf。

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

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. 我发现了问题的原因:我们是两个人在从事这个项目,他已经设置使用扩展文件,因此创建了两个文件(主APK和OBB扩展文件),我没有注意到,我只是加载了主APK文件,我猜数据库在OBB文件中。 After setting not to use an expansion file the app works. 设置为不使用扩展文件后,该应用即可运行。

 usesExpansionFile = false

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM