由网友(老娘傲不解释)分享简介:我使用了Android SQLite的,我想知道拿到我插入的行的生成ID的最佳方式。I'm using the SQLite with Android, and I want to know the best way to get the generated id of the row I inserted.有一个...
我使用了Android SQLite的,我想知道拿到我插入的行的生成ID的最佳方式。
I'm using the SQLite with Android, and I want to know the best way to get the generated id of the row I inserted.
有一个解决方案,我认为这是使搜索包括后,但它不看的最好方法。
A solution I think is make a search after include, but it's doesn't look the best way.
推荐答案
的insert方法返回 ID刚刚插入的行
或 1
如果有插入过程中出现错误。
The insert
method returns the id
of row just inserted or -1
if there was an error during insertion.
long id = db.insert(...);
其中db是 SQLiteDatabase
。
相关推荐
最新文章