I get the error:
android.database.sqlite.SQLiteException: no such column: app_table (code 1): , while compiling: SELECT _id FROM apps WHERE app_table=? AND app_row=? AND app_column=?
The "select" is called in this part of the code:
public int getKeyId(int table, int row, int column) {
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.query(DB_TABLE, new String[] { KEY_ID }, KEY_TABLE+ "=?" + " AND "
+ KEY_ROW+ "=?" + " AND "+ KEY_COLUMN+ "=?",
new String[] { String.valueOf(table), String.valueOf(row),
String.valueOf(column)}, null, null, null, null );
if (cursor.getCount()==0) {
return -1;
}
return cursor.getInt(0);
}
These are the strings I use to create the database:
private static final String TAG = "SQLiteOpenHelper";
private static final String DB_NAME = "apps_tables";
private static final int DB_VERSION = 1;
private static final String DB_TABLE = "apps";
/**
* Columns
*/
private static final String KEY_ID = "_id";
private static final String KEY_TABLE = "app_table";
private static final String KEY_ROW = "app_row";
private static final String KEY_COLUMN = "app_column";
private static final String KEY_NAME = "app_name";
/**
* Creation statement
*/
private static final String DB_CREATE = "CREATE TABLE " + DB_TABLE + " (" + KEY_ID +
" INTEGER PRIMARY KEY AUTOINCREMENT, " + KEY_TABLE + " INTEGER NOT NULL, "
+ KEY_ROW + " INTEGER NOT NULL, " + KEY_COLUMN + " INTEGER NOT NULL, " +
KEY_NAME +" TEXT NOT NULL);";
onCreate calls:
database.execSQL(DB_CREATE);
Does anyone know why do I get this error? Thanks!