Delete row in database table given one column value - which is a string

前端 未结 4 796
旧时难觅i
旧时难觅i 2020-12-03 11:09

I have a table with column headings: | _id (long) | Name (String) | x (integer) | y (integer) |

I want to delete the row in the table that has Name myName.



        
4条回答
  •  时光说笑
    2020-12-03 11:23

    Try putting the value of the where clause in quotes...

    KEY_NAME + "='" + myName + "'"
    

    Also, it is bad practice (generally) to use a string-based WHERE clause. This is because if my name has an apostrophe in it, your app will not work. You should probably look for an alternative way to delete records from a database on Android.

提交回复
热议问题