rowid in SQLITE3 and Android

£可爱£侵袭症+ 提交于 2019-12-10 16:34:12

问题


I perform an insert on a database and I want to know what the rowid is for that insert.

Does this accomplish the task:

Uri uri = ContentResolver.insert(url,values);    //Make insert
int rowid= Integer.parseInt(uri.getFragment());  //Get 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?


回答1:


To parse the URI after an insert and get the id you should use ContentUris.parseId(uri).



来源:https://stackoverflow.com/questions/6500445/rowid-in-sqlite3-and-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!