Himanshu
Himanshu

Reputation: 881

Record cannot be deleted

I have a Adapter class in which I have made a method to delete a record from the table. In my table there are only three fields: id, status(bool) and num. In this case when I try to delete a record with fire query with id than I achieve the deleting like:

public boolean deleteContact(long rowID){
  return db.delete(DATABASE_TABLE, KEY_ROWID + "=" + rowID, null) > 0;
}

But I want to delete record by number which is sqlite text data typeed:

public void deleteFromNum(String num){
  db.delete(DATABASE_TABLE, KEY_NUM + "=" + "740-514-8806", null);
}

Above method does not work. How can I fix it?

Upvotes: 0

Views: 48

Answers (1)

Alexander
Alexander

Reputation: 48232

Strings should be enclosed in ''

public void deleteFromNum(String num){
  db.delete(DATABASE_TABLE, KEY_NUM + "='" + "740-514-8806" + "'", null);
}

Upvotes: 1

Related Questions