I want to get the last_insert_rowid()
after my insert statement.
I wanted to use SQLiteDatabase.execSQL()
but it says that I can't use select statements there.
How can I use last_insert_rowid()
?
I want to get the last_insert_rowid()
after my insert statement.
I wanted to use SQLiteDatabase.execSQL()
but it says that I can't use select statements there.
How can I use last_insert_rowid()
?
I think you have used this method for insert data in sqlite database its give you new inserted row.
No need to use any another method.
public long insert (String table, String nullColumnHack, ContentValues values)
Parameters
table the table to insert the row into
nullColumnHack optional; may be null. SQL doesn't allow inserting a completely empty row without naming at least one column name. If your provided values is empty, no column names are known and an empty row can't be inserted. If not set to null, the nullColumnHack parameter provides the name of nullable column name to explicitly insert a NULL into in the case where your values is empty.
values this map contains the initial column values for the row. The keys should be the column names and the values the column values
It Returns the row ID of the newly inserted row, or -1 if an error occurred
like:
long a = database.insert("animals", null, values);
a
is your table's row id.