Android SQL : Find And Delete Item From SQL Database
I can't find out how to... first, find an item from an SQL database by searching for a string, and then deleting that found item. My database is just a list of strings. I have found out how to list the items, but I am not sure how to delete certain items fr开发者_如何学编程om it....
Use the DELETE statement:
DELETE FROM YOUR_TABLE
WHERE column_name = 'your_string'
Be careful
Test that the query will remove what you want it to by changing it to a SELECT before using the DELETE version:
SELECT * FROM YOUR_TABLE
WHERE column_name = 'your_string'
You might need to specify more details to isolate the record you want.
Without knowing exactly about your tables etc. I have this link for you.
First you will give in the name of your table next you pass in something like
"myColumn = ?"
and as where-args you pass in a stringarray with the string you want to look for. The safest way will be to give unique identifiers(primary keys) to each row. so you will be sure to delete the right record.
精彩评论