JJkk JJkk - 7 months ago 68
Android Question

Android SQLite database delete

I want to delete the all rows by dates. In the table I have the rows with this format:

. Now, I want to delete the all rows by date range.
I have created this method, but I believe there is a syntax error:

public void deleteAllEntrate_e_uscite(View v) {
SQLiteDatabase db = mHelper.getWritableDatabase();
db.delete(MyTable.TABLE_NAME, MyTable.DATA + "BETWEEN" +dateAndTime+ "AND" +dateAndTime1, null);



You need to separate your keywords:

MyTable.DATA + "BETWEEN" +dateAndTime+ "AND" +dateAndTime1

you need spaces AND you need apostrophes, since your dates are strings:

MyTable.DATA + " BETWEEN '" +dateAndTime+ "' AND '" +dateAndTime1 +"'"