我的App和Sqlite连接在模拟器上工作,但在android设备上发布时无法工作。
以下是示例代码,我已经尝试过,所有工作在模拟器上,但不是在android手机上
// SAMPLE-1
var conn:SQLConnection = new SQLConnection();
conn.addEventListener(SQLEvent.OPEN, openSuccess);
conn.addEventListener(SQLErrorEvent.ERROR, openFailure);
var fileLocation:File = File.applicationStorageDirectory.resolvePath("assets/weddingsql.sqlite"); ;
conn.openAsync(fileLocation, SQLMode.READ);
// SAMPLE-2
var fileLocation:File = File.applicationStorageDirectory.resolvePath("assets/weddingsql.sqlite"); ;
var storageDbFilePath:File = File.applicationStorageDirectory.resolvePath("weddingsql.sqlite");
fileLocation.copyToAsync(storageDbFilePath, true);
fileLocation.addEventListener(Event.COMPLETE, fileCopiedHandler);
function fileCopiedHandler(event:Event):void {
trace("File Copied....");
conn.openAsync(storageDbFilePath, SQLMode.READ);
}
// Used in both the samples
private function openSuccess(evt:SQLEvent):void{
trace(" can not make connection to Database "); }
private function openFailure(evt:SQLErrorEvent):void{
trace(" can not make connection to Database ");}最后,如果可能的话,我建议所有的as3 air开发者转移到本地的android。
发布于 2016-08-25 20:19:05
要在android中使用sqlite,请尝试在清单文件中添加:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>https://stackoverflow.com/questions/39103863
复制相似问题