得到一个新的记录的ID插入从返回乌里数据库数据库、ID

由网友(未知の未來)分享简介:当你插入一个新的项目进入这样一个数据库When you insert a new item into a database like this Uri uri = getContentResolver().insert(Tournaments.CONTENT_URI, values); 有没有什么办法让从返回的UR...

当你插入一个新的项目进入这样一个数据库

When you insert a new item into a database like this

Uri uri = getContentResolver().insert(Tournaments.CONTENT_URI, values); 

有没有什么办法让从返回的URI的ID,这样我就不必运行一个查询,以获得ID,因为它已经在返回的URI?

is there any way to get the id from the uri that is returned so I don't have to run a query to get the id since its already in the returned uri?

推荐答案

ContentUris.parseId()最后路径段转换为long。

ContentUris.parseId() converts the last path segment to a long.

阅读全文

相关推荐

最新文章