Android的SQLite的:last_insert_rowid()插入后 [英] Android Sqlite: last_insert_rowid() after insert

查看:166
本文介绍了Android的SQLite的:last_insert_rowid()插入后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要得到的 last_insert_rowid()我的INSERT语句之后。

I want to get the last_insert_rowid() after my insert statement.

我想用 SQLiteDatabase.execSQL(),但它说,我不能用select语句那里。

I wanted to use SQLiteDatabase.execSQL() but it says that I can't use select statements there.

如何使用 last_insert_rowid()

推荐答案

我想你已经使用了插入数据这种方法在SQLite数据库的给你新的插排。

I think you have used this method for insert data in sqlite database its give you new inserted row.

无需使用任何其他方法。

众长插入(字符串表,字符串nullColumnHack,ContentValues​​值)

参数

插入一行到

nullColumnHack 可选的;可以为null。 SQL不允许插入一个完全空行不点名至少有一列名。如果提供的值是空的,没有列名已知的,并且一个空行不能被插入。如果没有设置为null,则nullColumnHack参数提供空列名的名称明确地插入空到在你的价值观是空的情况。

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

返回
新插入的行的行号,或-1,如果发生错误

这样的:

long a = database.insert("animals", null, values);

A 是表的行ID。

这篇关于Android的SQLite的:last_insert_rowid()插入后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆