I'm getting this error when I run my app:
01-09 17:44:29.317: E/AndroidRuntime(3697): Caused by: android.database.sqlite.SQLiteException: no such column: title: , while compiling: SELECT title , _id FROM Kwl
I've looked up other solutions, but they were all due to a missing "_id" column, which I have.
Here is the related snippet from my Activity:
final DatabaseHelper db = new DatabaseHelper(this);
Cursor c = db.getKwlNames();
startManagingCursor(c);
String[] from = new String[] { DatabaseHelper.KWL_TITLE, DatabaseHelper.KWL_ID };
int[] to = new int[] { R.id.titleLI_title, R.id.titleLI_id };
SimpleCursorAdapter sca = new SimpleCursorAdapter(this,
R.layout.title_list_item, c, from, to);
listView.setAdapter(sca);
and the code from my DatabaseHelper:
public class DatabaseHelper extends SQLiteOpenHelper {
public static final String DATABASE_NAME = "KWL_DB";
public static final String KWL_TABLE = "Kwl";
public static final String CHART_TABLE = "Chart";
public static final int DATABASE_VERSION = 1;
public static final String KWL_TITLE = "title";
public static final String KWL_ORDER = "seq";
public static final String KWL_HASE = "hase";
public static final String KWL_ID = "_id";
public static final String CHART_TYPE = "type";
public static final String CHART_ORDER = "seq";
public static final String CHART_VALUE = "val";
public static final String CHART_KWL_TITLE = "title";
static final String CREATE_KWL = "CREATE TABLE " + KWL_TABLE + " (" + KWL_ID
+ " INTEGER PRIMARY KEY AUTOINCREMENT, " + KWL_TITLE
+ " TEXT, " + KWL_ORDER + " INTEGER, " + KWL_HASE
+ " INTEGER)";
static final String CREATE_CHART = "CREATE TABLE " + CHART_TABLE + " (" + CHART_KWL_TITLE
+ " TEXT, " + CHART_VALUE + " TEXT, " + CHART_ORDER
+ " INTEGER, " + CHART_TYPE + " TEXT)";
public DatabaseHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(CREATE_KWL);
db.execSQL(CREATE_CHART);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
public Cursor getKwlNames() {
SQLiteDatabase db = this.getReadableDatabase();
return db.rawQuery("SELECT " + KWL_TITLE + " , " + KWL_ID + " FROM " + KWL_TABLE, null);
}
}