When i do seperate queries like this, i can get what query says. I want to retrieve events according to type and time,i want events not ended, and today but not started so, that is query maker code:
db = this.getWritableDatabase();
if(cursor.moveToFirst()==false){
Log.e(TAG,"null");
return null;
}//bulamadıysa hic null dondruyor
// Log.e(TAG,"cursor: "+cursor.getColumnNames());
// looping through all rows and adding to list
if (cursor.moveToFirst()) {
do {
Event event = new Event();
// event.setID(Integer.parseInt(cursor.getString(0)));
event.setName(cursor.getString(1));
event.setDescription(cursor.getString(7));
event.setLink(cursor.getString(4));
event.setLocation(cursor.getString(2));
event.setType(cursor.getString(3));
event.setStartDate(cursor.getString(5));
event.setEndDate(cursor.getString(6));
// to show user if correct, write screen
eventList.add(event);
event.writeSc(event);
} while (cursor.moveToNext());
}
db.close();
return eventList;
}
First i make seperate, this is working:
String selectQuery = "SELECT * FROM " + TABLE_EVENTS+
" WHERE ("
+ KEY_START_TIME+" <= '"+formatter.format(currentDate.getTime())+"'"
+" AND "
+ KEY_END_TIME+ " >= '"+formatter.format(currentDate.getTime())+"') "+
" OR ("+KEY_END_TIME + " BETWEEN '"+formatter.format(currentDate.getTime())+"' " +
"AND '"+formatter.format(currentDate.getTime()).substring(0,10)+ " 23:59')" +
// " AND "+
//KEY_TYPE+" = \""+type_+"\""
" ORDER BY "+ KEY_START_TIME +" ASC";
Also this is working
String selectQuery = "SELECT * FROM " + TABLE_EVENTS+
" WHERE "
// + KEY_START_TIME+" <= //'"+formatter.format(currentDate.getTime())+"'"
// +" AND "
// + KEY_END_TIME+ " >= //'"+formatter.format(currentDate.getTime())+"') "+
// " OR ("+KEY_END_TIME + " BETWEEN //'"+formatter.format(currentDate.getTime())+"' " +
// "AND //'"+formatter.format(currentDate.getTime()).substring(0,10)+ " 23:59')" +
// // " AND "+
KEY_TYPE+" = \""+type_+"\""
" ORDER BY "+ KEY_START_TIME +" ASC";
But when i merge them, it doesnot work. It was working but i dont know whathappened. And i know, they are sometting common, they have some events togeteher but retrieves all kind of events when i make together
String selectQuery = "SELECT * FROM " + TABLE_EVENTS+
" WHERE ("
+ KEY_START_TIME+" <= '"+formatter.format(currentDate.getTime())+"'"
+" AND "
+ KEY_END_TIME+ " >= '"+formatter.format(currentDate.getTime())+"') "+
" OR ("+KEY_END_TIME + " BETWEEN '"+formatter.format(currentDate.getTime())+"' " +
"AND '"+formatter.format(currentDate.getTime()).substring(0,10)+ " 23:59')" +
" AND "+
KEY_TYPE+" = \""+type_+"\""
" ORDER BY "+ KEY_START_TIME +" ASC";
I can paste wrong but they are correct, studio doesnot give errors. Please help. ıicant see it for days, i am really nervous. It must be maybe small thing but i am not able to see it no more.
Aucun commentaire:
Enregistrer un commentaire