Reputation: 913
I need to delete a specific row from table in my SQLite database.
This table contains paths to files.
And I need to delete paths, which contain specific extensions.
And I have troubles with this.
Nothing is deleted from my database.
For example my table name is ALL_PATHS and column name is PATH_NAME
This is the way I am doing this.
I'll be very glad for any help thanks
private void deletePath(String extension){
Database db = getWritableDatabase();
String query = "DELETE FROM " + ALL_PATHS + " WHERE lower(" + PATH_NAME + ") LIKE '%" + extension + "'";
Cursor cursor = db.rawQuery(query, null);
}
Upvotes: 1
Views: 86
Reputation: 554
use Content values
String table = "beaconTable";
String whereClause = "_id" + "=?";
String[] whereArgs = new String[] { String.valueOf(row) };
db.delete(table, whereClause, whereArgs);
Upvotes: 0
Reputation: 38098
The error is:
Cursor cursor = db.rawQuery(query, null);
While it should be
db.execSQL(query);
Because DELETE
is a command, not a query (SELECT
)
Upvotes: 5