Androidでsqliteを使用してgroup by句に問題があります。最後のレコードのみを表示します
これは私のデータベース関数です:
public List<Expense> getAllExpenses() {
List<Expense> ExpenseList = new ArrayList<Expense>();
// Select All Query
String selectQuery = "SELECT * FROM "+ ExpenseTable+" GROUP BY "+colCategoryId+"" ;
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
// looping through all rows and adding to ist
if (cursor.moveToFirst()) {
do {
Expense expense = new Expense();
expense.setItem_Desrp(cursor.getString(1));
expense.setPrice(Integer.parseInt((cursor.getString(2))));
expense.setDate(cursor.getString(3));
expense.setMode(cursor.getString(4));
expense.setCate_Id(Integer.parseInt(cursor.getString(5)));
// Adding expense to list
ExpenseList.add(expense);
} while (cursor.moveToNext());
}
return ExpenseList;
}