JJkk JJkk - 1 year ago 100
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);


Answer Source

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 +"'"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download