Browse Tag

adobe air

get Column names SQLite tables using Adobe AIR + Javascript


var db = air.File.documentsDirectory.resolvePath("[database path / database name]");
conn = new air.SQLConnection();
conn.open(db);
sql = new air.SQLStatement();
sql.sqlConnection = conn;

conn.loadSchema();
ax = conn.getSchemaResult();

var col = [];

sc = ax.tables;
error(sc);
num = sc.length;
for (var i=0;i<num;i++){
    if (sc[i].name == "[table name contains the column]"){
        numc = sc[i].columns.length;
        for (var y=0;y<numc;y++){
            nn = sc[i].columns[y].name;
            col.push(nn);
            error(y);
        }
    }
}

var cx = 0;
for (var x=0;x<col.length;x++){
    error(col[x]);
    if (col[x] == "[column name we are looking for]"){
        cx = 1;
    }
}
error(cx);
if (cx != 1){
        sql.text = "ALTER TABLE [tablename] ADD COLUMN [column name] TEXT";
        sql.execute();
        error("altered");
}else{
    error("not altered");
}

Adobe Air – preparasi

Tes Aplikasi

untuk tes aplikasi, tanpa harus compile via Dreamweaver :


./adl -runtime [path_to_Adobe AIR.framework folder] my_application.xml

kalau yang biasa saya pakai ada di :

./adl -runtime /Users/dilardarmawan/Documents/AdobeAIRSDK/runtimes/air/mac/ my_application.xml

Console Debug

untuk console, dapat memakai AirInstrospector.js

cukup include kan di file index.html atau terserah dimana. untuk mendapatkan log bisa menggunakan :

air.Introspector.Console.log();

selengkapnya di SINI