This completes the task:
Uri uri = ContentResolver.insert(url,values); //Make insert
int rowid = Integer.parseInt(uri.getFragment()); //Get rowid
The Android document states that inserting returns “URL of the newly created row”. And the Uri method getFragment() should return everything after /#. So, is my understanding correct, getFragment() will therefore return my rowid?
I perform an insert operation on the database, and I want to know what rowid should be inserted.
This completes the task:
Uri uri = ContentResolver.insert(url,values); //Make insert
int rowid = Integer.parseInt(uri.getFragment()); //Get rowid
The Android document states that inserting returns “URL of the newly created row”. And the Uri method getFragment() should return everything after /#. So, is my understanding correct, getFragment() will therefore return my rowid?
To parse the URI and get the id after insertion, you should use ContentUris.parseId(uri).