Corona - 适用于模拟器但不适用于真正的Android设备(system.pathForFile)

时间:2016-01-06 12:20:48

标签: lua corona

我有这个简单的代码行在模拟器上完美运行但在实际的Android设备上得到library(doParallel) library(RMySQL) library(DBI) library(foreach) cl <- makeCluster(12) registerDoParallel(cl) Postcodecsv <- read.csv("C:/Users/Henry Crosby/Desktop/PostcodeLatLong.csv") mydb = dbConnect(MySQL(), user='****', password="******* ****", dbname='population_distance', host='****.**.*.*') dbListFields(mydb,'Postcodes') foreach (a = 1:120000, .combine="rbind") %dopar% { Done <- dbGetQuery(mydb, paste("select FID, Postcode2, (6371 * acos( cos( radians( ",Postcodecsv[a,6],"))*cos(radians(latitude))*cos(radians(Longitude)-radians(",Postcodecsv[a,5],"))+sin(radians(",Postcodecsv[a,6],") )* sin( radians( latitude ) ) ) ) AS distance from Postcodes having distance < 2 ORDER BY distance",sep=" ")) write.table(Done,file="C:/Users/Henry Crosby/Desktop/2km.csv",append=TRUE, col.names=FALSE, sep=",") }

nil
我得到的Android设备上的

运行时错误.......尝试连接本地'path'(零值)

我阅读了android文档,它说你不需要读取内部存储空间的权限。

导致此错误的原因是什么? 怎么解决?

我是否需要添加任何特殊权限才能在android中使用local path = system.pathForFile( nil, system.ResourceDirectory) print('path', path) path = path .. "/assets/audios"

1 个答案:

答案 0 :(得分:0)

好的......发现一些不适用于Android设备的东西。 它有点作弊/解决方法......但只要它有效......

所以这在设备上不起作用,但在模拟器上工作:

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


print('path', path)

path = path .. "/assets/audios"

然而,这可以通过不同的步骤获得相同的结果:

local path = system.pathForFile('assets/audios/x.wav', system.ResourceDirectory)

    -- path = path .. "/assets/audios"
    path = string.gsub( path, 'x.wav', '' )