I'm trying to delete a row from a table in SQLite for the first time, I thought I'd followed a tutorial and adapted it to my app but I've messed up the syntax somewhere.
Here is the code from DatabaseHelper.java
public void deleteRow (String subject) {
SQLiteDatabase db = this.getWritableDatabase();
db.execSQL("delete from " + TABLE_NAME +" where " + COL_2 + "=" + subject);
}
And the code that calls it from SubjectActivity.java:
public void onClick(View view) {
if(view.getId()==R.id.deleteSubject) {
Bundle extras = getIntent().getExtras();
String subject = extras.getString("subject");
myDb.deleteRow(subject);
}
}
The row should be deleted when a delete button is pressed in the subject activity, but when I do press the button, the app force closes. What am I missing in the syntax?