I dont get it, it keep crashing even though i had check the code is correct. It just keeps telling me there is no such column date. I will post my codes here for DBHelper class.
private static final String DATABASE_NAME = "tasks.db";
private static final int DATABASE_VERSION = 1;
private static final String TABLE_TASK = "tasks";
private static final String COLUMN_ID = "id";
private static final String COLUMN_NAME = "name";
private static final String COLUMN_DESCRIPTION = "description";
private static final String COLUMN_DATE = "date";
@Override
public void onCreate(SQLiteDatabase db) {
String createTaskTableSql = "CREATE TABLE " + TABLE_TASK + "("
+ COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT,"
+ COLUMN_NAME + " TEXT, "
+ COLUMN_DESCRIPTION + " TEXT, "
+ COLUMN_DATE + " DATETIME DEFAULT CURRENT_TIMESTAMP )";
db.execSQL(createTaskTableSql);
}
public ArrayList<Lists> getAllLists() {
ArrayList<Lists> lists = new ArrayList<Lists>();
String selectQuery = "SELECT " + COLUMN_ID + ", "
+ COLUMN_NAME + ", " + COLUMN_DESCRIPTION + ", " + COLUMN_DATE + " FROM " + TABLE_TASK;
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
if (cursor.moveToFirst()) {
do {
int id = cursor.getInt(0);
String listsName = cursor.getString(1);
String desc = cursor.getString(2);
String date = cursor.getString(3);
Lists allLists = new Lists(id, listsName, desc, date);
lists.add(allLists);
} while (cursor.moveToNext());
}
cursor.close();
db.close();
return lists;
}
I cant identify the issue. Someone please help me out.