Search code examples
androidrowdelete-row

Delete last row in a table android


My question is quite straightforward. I have a table, with, lets say x rows, with each an id, but I don't know how many rows I have. Now I want to delete the last row of my table for some reason... Is there an easy way to do that in android? I have been trying to use the last_insert_rowid in my where clause...but no luck so far... Any idea to do that with the sqlite database tools of android?


Solution

  • I assume that last_insert_rowid means that you are talking about db.

    DELETE FROM test WHERE id = (SELECT MAX(id) FROM test);