我已经用open()方法构建了一个数据库辅助类,并且用onCreate()覆盖了扩展的sqlite帮助器。 (如下所示)。尽管如此,我得到'SQLiteException,没有这样的表'的错误。我不明白,为什么openHelper没有帮助?没有这样的表SQLite Android
public void open() {
try{
db = openHelper.getWritableDatabase();
} catch (SQLiteException e) {
db = openHelper.getReadableDatabase();
}
}
//other stuff
public static final String database_create = "create table " + database_table + " (" + primary_key + " integer primary key autoincrement, "
+ company_column + " text not null, " + product_column + " text not null);";
@Override
public void onCreate(SQLiteDatabase _db) {
_db.execSQL(database_create);
}
下面的代码是为了临时插入一个条目,因为数据库不能为其他原因为空。这似乎完美地执行,但代码的最后位,其中来自后就是引发错误
CompanyAndProductDatabaseAdapter cpdAdapter = new CompanyAndProductDatabaseAdapter(this);
cpdAdapter.open();
errorguard = cpdAdapter.insertPair("Loading", "...");
cpdAdapter.close();
//other stuff
cpdAdapter.open();
Cursor cursor = cpdAdapter.getAllPairsCursor(); //error here
cursor.requery();
startManagingCursor(cursor);
那怎样?如果你解决了它。请告诉它。并考虑接受答案 – Beasly 2011-02-14 19:02:15