SQLITE3和Android中的rowid [英] rowid in SQLITE3 and Android
本文介绍了SQLITE3和Android中的rowid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对数据库执行插入操作,我想知道该插入的rowid是什么。
I perform an insert on a database and I want to know what the rowid is for that insert.
这是否完成任务:
Uri uri = ContentResolver.insert(url,values); //Make insert
int rowid= Integer.parseInt(uri.getFragment()); //Get rowid
Android文档说明 insert
返回新创建的行的URL。而Uri方法 getFragment()
应该返回/#后的所有内容。所以,我的理解正确, getFragment()
将返回到我的rowid?
The Android documentation states that the insert
returns "the URL of the newly created row." And the Uri method getFragment()
is supposed to return everything after the /#. So, is my understanding correct that getFragment()
would thus return to me the rowid?
推荐答案
要在插入后解析URI并获取id,您应该使用 ContentUris.parseId(uri)
。
To parse the URI after an insert and get the id you should use ContentUris.parseId(uri)
.
这篇关于SQLITE3和Android中的rowid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文