I'm trying to batch delete some items in a table.
String ids = { "1", "2", "3" };
mContentResolver.delete(uri, MyTables._ID + "=?", ids);
However I keep getting this following error
java.lang.IllegalArgumentException: Too many bind arguments. 3 arguments were provided but the statement needs 1 arguments.
The error occurs because you have a single placeholder (?) in your where clause, while you pass three arguments. You should do:
String ids = { "1", "2", "3" };
mContentResolver.delete(uri, MyTables._ID + "=? OR " + MyTables._ID + "=? OR " + MyTables._ID + "=?", ids);
I do not know if SQLite supports the IN clause, if so you could also do:
String ids = { "1, 2, 3" };
mContentResolver.delete(uri, MyTables._ID + " IN (?)", ids);