I am developing a tutorial project and working with SQLite database. I am trying to retrieve records using WHERE on DATE column in database. But it is retrieving nothing. What is wrong with my code ?
The CREATE statement in database helper class
private static final String CREATE_TABLE = "CREATE TABLE " + TABLE_NAME + " ("
+ COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT,"
+ COLUMN_DESCRIPTION + " TEXT,"
+ COLUMN_DATE + " DATE,"
+ COLUMN_DONE + " BOOLEAN)";
This is how I am retrieving record
String date = "04-22-2014";
ArrayList<Task> tasks = new ArrayList<Task>();
db = getReadableDatabase();
String query = "SELECT * FROM "+TABLE_NAME + " where "+ COLUMN_DATE + " = "+ date;
Cursor cursor = db.rawQuery(query,null);
if(cursor.moveToFirst())
{
do{
Task task = new Task();
task.setId(cursor.getInt(0));
task.setDescription(cursor.getString(1));
task.setDate(cursor.getString(2));
task.setDone(Boolean.valueOf(cursor.getString(3)));
tasks.add(task);
}
while(cursor.moveToFirst());
}
return tasks;
But it is not returning any record.