public void insertRide(Ride ride) { ContentValues values = new ContentValues(); values.put("date", ride.getDate()); values.put("isPaid", ride.isIsPaid()); values.put("sentWs", ride.isSentWs()); db.insert("ride", null, values); }
public ArrayList<Ride> findAllRides() { ArrayList<Ride> rides = new ArrayList<Ride>(); String[] columms = new String[] {"_id", "date", "isPaid", "sentWs"}; Cursor cursor = db.query("ride", columms, null, null, null, null, null); if (cursor.getCount() > 0) { cursor.moveToFirst(); do { Ride ride = new Ride(); ride.setId(cursor.getInt(0)); ride.setDate(cursor.getString(1)); ride.setIsPaid(cursor.getInt(2) == 1); ride.setSentWs(cursor.getInt(3) == 1); rides.add(ride); } while (cursor.moveToNext()); } return rides; }
public void updateRide(Ride ride) { ContentValues values = new ContentValues(); values.put("isPaid", ride.isIsPaid()); values.put("sentWs", ride.isSentWs()); db.update("ride", values, "_id = ?", new String[] {String.valueOf("" + ride.getId())}); }
public void deleteRide(Ride ride) { String selection = "_id " + " = ?"; String[] selectionArgs = {String.valueOf(ride.getId())}; db.delete("ride", selection, selectionArgs); }