Can sqlite databae be used with as3 air app for android devices running 6.0+ versions?

£可爱£侵袭症+ 提交于 2020-01-06 21:39:22

问题


My App and Sqlite connection works on simulator but does not work when publishes on android device.

Below are the sample codes, I have tried, all work on simulator but not on android phone

 // 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 ");}

And lastly, I suggest all as3 air developer to move on to native android if possible.


回答1:


to use sqlite in android try add in manifest file:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>


来源:https://stackoverflow.com/questions/39103863/can-sqlite-databae-be-used-with-as3-air-app-for-android-devices-running-6-0-ver

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!