访问 Android 上的预填充表,出现错误“No such table: TableName”
我有一个预填充的数据库,位于我的资产文件夹中,并在下载到模拟器时复制到我的 /data/data/com.package/database 文件夹。我正在尝试通过 Phonegap sql 调用访问此数据库。我已检查该表是否已正确移植到模拟器,并且所有数据均正确。但是我不断收到未找到表的错误。我对应用程序开发还很陌生,所以这可能是一个简单的解决方案。谢谢。
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
var db = window.openDatabase("careerDB.db", "", "Career DB", 60416);
var careers;
errorHandler = function(){
$('#careerList').append('Error!');
}
db.transaction(getCareerList);
function getCareerList(transaction){
transaction.executeSql('SELECT * FROM Careers',[], function(transaction, results) {
$('#careerList li').remove();
for(var i=0;i<results.rows.length;i++){
var row = results.rows.item(i);
$('#careerList').append('<li><a href="closestCareers.html?id=' + row['id'] + '"><h4>' + row['career'] + '</h4></a></li>');
}
$('#careerList').listview('refresh');
},errorHandler);
}
}
I have a prepopulated database that resides in my assets folder and is copied to my /data/data/com.package/database folder when downloaded to the emulator. I am trying to access this database via Phonegap sql calls. I have checked that the table is correctly being ported to the emulator and all of the data is correct. I keep getting an error of table not found however. I am pretty new to app dev so this could be an easy fix. Thanks.
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
var db = window.openDatabase("careerDB.db", "", "Career DB", 60416);
var careers;
errorHandler = function(){
$('#careerList').append('Error!');
}
db.transaction(getCareerList);
function getCareerList(transaction){
transaction.executeSql('SELECT * FROM Careers',[], function(transaction, results) {
$('#careerList li').remove();
for(var i=0;i<results.rows.length;i++){
var row = results.rows.item(i);
$('#careerList').append('<li><a href="closestCareers.html?id=' + row['id'] + '"><h4>' + row['career'] + '</h4></a></li>');
}
$('#careerList').listview('refresh');
},errorHandler);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论