我有四个选项卡,第一个选项卡在数据库上插入数据,另外两个选项卡负责使用光标显示数据。这里是我的问题,虽然当我第一次启动应用程序,并且数据库上没有任何内容,如果我按下2个选项卡中的其中一个,它会给我出现此错误:当打开一个TAB和数据库为空时出现Sqlite错误Android
错误/ AndroidRuntime:引起:android.database.sqlite.SQLiteException :没有这样的表
我的问题是如何避免在按下2个选项卡中的一个时出现此错误,我只想显示空白列表的空白选项卡。 这里是一段代码中错误发生:
void populate() {
array = new ArrayList<String>();
mydb = openOrCreateDatabase("vivo_id.db",
SQLiteDatabase.CREATE_IF_NECESSARY, null);
Cursor c = mydb.query("VIVOID", null, null, null, null, null, null);
// start the managing cursor
startManagingCursor(c);
// move to first row
c.moveToFirst();
// continue searching until it is the last row in the column
while (c.isAfterLast() == false) {
sharable = c.getString(c.getColumnIndex("isCouponSharable"));
coupon = c.getString(c.getColumnIndex("couponImageResult"));
rawImage = c.getString(c.getColumnIndex("couponThumbnailResult"));
keyword = c.getString(c.getColumnIndex("keyword"));
histDesRes = c.getString(c.getColumnIndex("couponDescription"));
history = keyword + " \n " + histDesRes + " " + "<@>" + ""
+ rawImage+""+"<@>"+""+coupon+""+"<@>"+""+sharable;
array.add(history);
c.moveToNext();
}
strings = array.toArray(new String[array.size()]);
// close everything
c.close();
mydb.close();
}
任何帮助或指针将不胜感激,谢谢你这么多提前。
请你详细说明答案,我真的很感激它。 – 2010-11-03 07:29:42