No consigo filtrar por fecha de inicio fecha de fin sobre un SQLite.
Para ello he creado un método el cual se le pasa 2 fechas, una de inicio y otra de fin.
private void consultarListaDietas(Date di, Date df) {
SQLiteDatabase db =conn.getReadableDatabase();
Dieta dieta=null;
Date date = new Date();
Cursor cursor = db.rawQuery("SELECT * FROM "+Utilidades.TABLA_DIETAS,null);
if (di==null && df==null){
while (cursor.moveToNext()){
dieta = new Dieta();
dieta.setId_Dieta(cursor.getInt(0));
dieta.setNoches(cursor.getInt(1));
dieta.setKm(cursor.getDouble(2));
String fecha = cursor.getString(3)
DateFormat iso8601Format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
date = iso8601Format.parse(fecha);
} catch (ParseException e) {
Log.e(TAG, "Parsing ISO8601 datetime failed", e);
}
dieta.setFecha(date);
dieta.setId_Usuario_FK(cursor.getInt(4));
dieta.setId_Proyecto_FK(cursor.getInt(5));
}
}else{
cursor=null;
Date[] args = new Date[]{di,df};
cursor = db.rawQuery("SELECT * FROM "+Utilidades.TABLA_DIETAS + " WHERE BETWEEN di AND df",args);
}
}
El problema lo tengo en el else, en los args me aparece un error "Wrong 2nd argument type". He comprobado que tanto el argumento di como df son argumentos tipo Date. Supongo que tengo algún problema en mi consulta.
Gracias de antemano!!