我有这段代码可以返回 Long A 和 Long B 之间的所有行
public ArrayList<CashGame> getAllCashGamesByDates(Long startdate, Long enddate) {
ArrayList<CashGame> cashgameList = new ArrayList<CashGame>();
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor= db.query(TABLE_CASHGAMES, new String[] { KEY_ID,
KEY_NAME, KEY_BUYIN, KEY_RESULT, KEY_START, KEY_END, KEY_LOCATION }, startdate + ">=? AND " + enddate + " <?",
new String[]{startdate.toString(), enddate.toString()} , null, null, null);
// looping through all rows and adding to list
if (cursor.moveToFirst()) {
do {
CashGame cashgame = new CashGame();
cashgame.setId(Integer.parseInt(cursor.getString(0)));
cashgame.setName(cursor.getString(1));
cashgame.setBuyin(cursor.getDouble(2));
cashgame.setResult(cursor.getDouble(3));
cashgame.setStartDate(date = new Date(cursor.getLong(4)));
cashgame.setEndDate(date = new Date(cursor.getLong(5)));
cashgame.setLocation(cursor.getString(6));
// Adding contact to list
cashgameList.add(cashgame);
} while (cursor.moveToNext());
}
db.close();
// return contact list
return cashgameList;
}
我想查询有问题,但我没有发现我犯的错误。希望有人看到!