List of usage examples for android.database.sqlite SQLiteBindOrColumnIndexOutOfRangeException SQLiteBindOrColumnIndexOutOfRangeException
public SQLiteBindOrColumnIndexOutOfRangeException(String error)
From source file:io.requery.android.database.sqlite.SQLiteConnection.java
private void bindArguments(PreparedStatement statement, Object[] bindArgs) { final int count = bindArgs != null ? bindArgs.length : 0; if (count != statement.mNumParameters) { String message = "Expected " + statement.mNumParameters + " bind arguments but " + count + " were provided."; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { throw new SQLiteBindOrColumnIndexOutOfRangeException(message); } else {/*from w w w . j a v a2 s.co m*/ throw new SQLiteException(message); } } if (count == 0) { return; } final long statementPtr = statement.mStatementPtr; for (int i = 0; i < count; i++) { final Object arg = bindArgs[i]; switch (getTypeOfObject(arg)) { case Cursor.FIELD_TYPE_NULL: nativeBindNull(mConnectionPtr, statementPtr, i + 1); break; case Cursor.FIELD_TYPE_INTEGER: nativeBindLong(mConnectionPtr, statementPtr, i + 1, ((Number) arg).longValue()); break; case Cursor.FIELD_TYPE_FLOAT: nativeBindDouble(mConnectionPtr, statementPtr, i + 1, ((Number) arg).doubleValue()); break; case Cursor.FIELD_TYPE_BLOB: nativeBindBlob(mConnectionPtr, statementPtr, i + 1, (byte[]) arg); break; case Cursor.FIELD_TYPE_STRING: default: if (arg instanceof Boolean) { // Provide compatibility with legacy applications which may pass // Boolean values in bind args. nativeBindLong(mConnectionPtr, statementPtr, i + 1, (Boolean) arg ? 1 : 0); } else { nativeBindString(mConnectionPtr, statementPtr, i + 1, arg.toString()); } break; } } }