MTilsted MTilsted - 1 month ago 4x
Android Question

In which case will sqlite executeInsert return -1?

The documentation for executeInsert in the SQLiteStatement class say that:

@return the row ID of the last row inserted, if this insert is successful. -1 otherwise.

But it can also cast an exception if the query fails, so in what cases will it choose to return -1 instead of throwing an exception?


It is possible to have an INSERT statement that is valid SQL but that does not actually insert any record. When using the INSERT ... SELECT form, the SELECT query might not actually return any records.