由于sdcard存储是只读模式,flex4.5移动开发操作sqlite数据库时,只能查询,不能insert,update,delete,所以初始化应用的时候要把sqlite的数据库copy的程序安装的目录下,代码如下:
var dbFiledb:File = new File("/mnt/sdcard/erppos/erppos.db");
var dbWorkFile:File = File.applicationStorageDirectory.resolvePath("database/erppos.db");
if(!dbWorkFile.exists){
dbFiledb.copyTo(dbWorkFile);
}
建立连接的时候:
file = File.applicationStorageDirectory.resolvePath("database/erppos.db"); sqlConnection = new sqlConnection(); sqlConnection.addEventListener(sqlEvent.OPEN,openHandler); sqlConnection.addEventListener(sqlErrorEvent.ERROR,errorHandler); stmt = new sqlStatement(); stmt.sqlConnection = sqlConnection; sqlConnection.open(file);