I built a database helper class using the open () method and the sqlite extended helper with overridden onCreate (). (shown below). Despite all this, I get an SQLiteException error, not such a table. I do not understand why openHelper does not help?
public void open() {
try{
db = openHelper.getWritableDatabase();
} catch (SQLiteException e) {
db = openHelper.getReadableDatabase();
}
}
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);
}
The following code is intended to temporarily insert a record because the database cannot be empty for other reasons. It seems to be executed perfectly, but the last bit of code that appears after that causes an error
CompanyAndProductDatabaseAdapter cpdAdapter = new CompanyAndProductDatabaseAdapter(this);
cpdAdapter.open();
errorguard = cpdAdapter.insertPair("Loading", "...");
cpdAdapter.close();
cpdAdapter.open();
Cursor cursor = cpdAdapter.getAllPairsCursor();
cursor.requery();
startManagingCursor(cursor);
source
share