The code for the following examples should again look very familiar. And like I said earlier, half of the challenge is just mastering the schema and understanding how each table interacts with the others (it helps to see the schema laid out like previously – otherwise it can be extremely confusing and may require browsing through a lot of verbose documentation). Let's say we want to insert a new phone number for a user. Which table's URI should we reference?
Well, it'd have to be one of the Data
tables and we should probably pass in the MIMETYPE
of the data so that the content provider knows exactly which of the Data
tables to insert the new row in. In this case, we'll specify the phone content type and pass in a number and a number type. The only field we're missing is the ID – whose phone Data
table should this new row go into? Well, recalling that each Data
table points to a Raw Contact
table, it would make sense to pass in the raw contact ID of the contact.
So we try...