[英]Visual Studio 2015 apache cordova
我有一个应用程序,它使用 WebSQL 事务来创建表、插入数据和从数据库中检索信息。
该应用程序在 Ripple Nexus (Galaxy) 上运行良好,但不适用于设备 (Galaxy Note 5) 和模拟器。 UI在那里:文本框,标签,按钮等。但是,根据我的注意,不执行对数据库的操作。
我能做什么?
这里没有足够的细节来说明发生了什么,也没有代码示例。 请注意,ripple 使用的是 http,而您设备上的应用程序可能使用的是非 http:// 调用位置。 另一个可能的问题是,在您的机器上有到本地 http 端点的 Web 连接,而在设备上,端点将不可用,除非它在互联网上公开/可供设备使用。
这是我的代码示例,打开数据库并填充数据表:
document.addEventListener('deviceready', onDeviceReady.bind(this), false);
var db = openDatabase('DUTIESDB', '1.0', 'Test DB', 2 * 1024 * 1024);
db.transaction(function (tx) {
tx.executeSql("DROP TABLE DUTIES", []);
tx.executeSql("DROP TABLE SDUTIES", []);
tx.executeSql('CREATE TABLE IF NOT EXISTS DUTIES (id, name, date, time, course, room)');
tx.executeSql('CREATE TABLE IF NOT EXISTS SDUTIES (id, name, date, time, course, room, invg)');
});
PupulateSupTable();
function PopulateSupTable() {
var xmlhttp = new XMLHttpRequest();
var url = "/scripts/SupDuties.txt";
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var myArr = JSON.parse(xmlhttp.responseText);
db.transaction(
function (tx) {
var k, sql = 'INSERT INTO SDUTIES (id, name, date, time, course, room, invg) VALUES (?,?,?,?,?,?,?)';
for (k = 0; k < myArr.length; k++) {
tx.executeSql(sql, [myArr[k].ID, myArr[k].Name, myArr[k].Date, myArr[k].Time, myArr[k].Course, myArr[k].Room, myArr[k].Invigilator]);
}
}
);
}
};
xmlhttp.open("GET", url, true);
xmlhttp.send();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.