You are not deleting the data I want from DataBase

-2

I have this code that supposedly deletes from the dataBase the date that I put in the method. But this is not erasing from the dataBase and I do not understand why. Here is the information:

    public void deleteRowWhitDate(String date){
    String query = "DELETE FROM " + TABLE_NAME+ " WHERE "+ COL_4 + " = " + date ;
    database.execSQL(query);
}

I'm sure the dataBase contains the date that I put in date.

      public static final String TABLE_NAME = "Exames_table";
    public static final String COL_4 = "DIA";

Doing the

Log.d("debug",query);

I got:

  

DELETE FROM Exames_table WHERE DAY = 07-30-2017

    
asked by anonymous 03.08.2017 / 18:15

1 answer

1

If you defined the column as TEXT, then the problem is that plics (') were missing in the comparison parameter of your SQL query. Should be yes:

String query = "DELETE FROM " + TABLE_NAME+ " WHERE "+ COL_4 + " = '" + date + "'";
    
03.08.2017 / 19:42