Here I have an array of IDs and the update method works only if its 1 ID in the array, but if I put 2-3 it gives me an error..something like: Too many bind arguments. 4 arguments were provided but the statement needs 2 arguments
How can I make it work. I want to set the same value in the same column for different IDs.
ContentValues values = new ContentValues();
values.put(DataEntry.COLUMN_DATA, "1");
String selection = DataEntry._ID + "=?";
String[] selectionArgs = selectedData.toArray(new String[selectedData.size()]);
// To be a bit more clear the above line looks like this:
// String[] selectionArgs = { 1, 2, 3, 4, 5 }; String array of IDs which varies
int rowsAffected = getContentResolver().update(DataEntry.CONTENT_URI, values, selection, selectionArgs);
The update method is as follows:
SQLiteDatabase db = mDbHelper.getWritableDatabase();
int rowsUpdated = db.update(DataEntry.TABLE_NAME, values, selection, selectionArgs);
I believe that you could use :-
Alternately you could use
WHERE IN (list of id's)
which could be along the lines of :-Of course you could loop through applying x placeholders. This would be along the lines of :-