我在使用此方法时遇到问题:createTable.execute()!!!!!我在Windows的空气中没有问题,但在android的空气中没有出现任何anny错误,但游戏在第1帧停止了。导入flash.data.SQLConnection;导入flash.events.SQLErrorEvent;导入flash.events.SQLEvent;导入flash.filesystem.File;导入flash.data.SQLStatement;导入flash.data.SQLMode;导入flash.data.SQLResult;导入flash.errors.SQLError;
var conn: SQLConnection = new SQLConnection();
conn.addEventListener(SQLEvent.OPEN, openHandler);
conn.addEventListener(SQLErrorEvent.ERROR, errorHandler);
// The database file is in the application storage directory
var folder: File = File.applicationStorageDirectory;
var dbFile: File = folder.resolvePath("DBSave1.db");
//conn.openAsync(dbFile);
conn.openAsync(dbFile);
function openHandler(event: SQLEvent): void {
trace("#############the database was created successfully#############");
}
function errorHandler(event: SQLErrorEvent): void {
trace("#############Error message############# :", event.error.message);
trace("#############Details err############# :", event.error.details);
}
trace("+++++++++++++++++++++++++++++++");
var createTable: SQLStatement = new SQLStatement();
createTable.sqlConnection = conn;
var table: String = "CREATE TABLE IF NOT EXISTS savegame (" + "uId INTEGER PRIMARY KEY AUTOINCREMENT, " + "firstParam TEXT, " + "secondParam TEXT, " + "thirdParam TEXT " + ")";
createTable.text = table;
try {
createTable.execute();
trace("Table created");
} catch (error: SQLError) {
trace("Error message:", error.message);
trace("Details:", error.details);
}
我必须在openHandler()中放置另一个函数。首先,我们应该打开数据库,并在其功能中执行与数据库有关的另一项操作。