问题
I get the IllegalArgumentException above when executing the function below. What I don't get is that when I run the debugger, the values variable clearly only contains 4 arguments, as it should.
So...
(1) Where does this mysterious fifth argument come from?
(2) How should I approach finding this error?
db.update(
UppdragEntry.TABLE_NAME,
values,
selection,
selectionArgs);
回答1:
Selection contains the following: String selection = "_id"; String[] selectionArgs = {" =" + personId};
You have a value in selectionArgs
but no ?
placeholder for it in selection
.
Change it to
String selection = "_id = ?";
String[] selectionArgs = { "" + personId };
The method builds an SQL string. Supplied ContentValues
are built as ?
placeholder and bind arguments. Additional selection args are also provided as bind arguments and they must be matched with equal number of ?
placeholders.
来源:https://stackoverflow.com/questions/24797635/too-many-bind-arguments-5-arguments-were-provided-but-the-statement-needs-4-arg