public static FoodItem getAnObject(Databases db, FoodItem item) { FoodItem gradeTemp = null; SQLiteDatabase dbRead = db.getReadableDatabase(); String query = "select * from " + TABLE_NAME + " WHERE " + FOOD_ID + " = " + item.id + ""; LOG.log("Query:", "Query:" + query); Cursor c = dbRead.rawQuery(query, null); if (c.moveToFirst()) { gradeTemp = getAnObjectFromCursor(c); } c.close(); dbRead.close(); return gradeTemp; }
public static ArrayList<FoodItem> getAllObject(Databases db) { ArrayList<FoodItem> grades = new ArrayList<FoodItem>(); SQLiteDatabase dbRead = db.getReadableDatabase(); String query = "select * from " + TABLE_NAME; LOG.log("Query:", "Query:" + query); Cursor c = dbRead.rawQuery(query, null); if (c.moveToFirst()) { do { FoodItem gradeTemp = getAnObjectFromCursor(c); grades.add(gradeTemp); } while (c.moveToNext()); } c.close(); dbRead.close(); return grades; }