K
K
KnightForce2015-04-14 22:54:05
Android
KnightForce, 2015-04-14 22:54:05

What happens in the marked code? And what is the ContentResolver query asking?

84548dcac6ad42f584983ddc90edc719.png
Explain (and correct) what happens in this code:
(3) get a Cursor object that contains a table from a content provider containing contacts, and ContactsContact.Contacts.CONTENT_URI is a reference to the table in the ContentProvider.
(4) Get the value of the "_id" column by its index. So?
(5) What is it and why? As I understand it, we take the path to the table in the ContentProvider and add a further path to the "_id" column. So?
Next, we pack it into an Intent and send it to the parent activity.
(1) After receiving data from the incoming Intent using the query method, it directly requests the Cursor, which will contain the "_id" column.
(2) And here I am confused.
Why getString method? As I understand it, to get some value from a column.
But internally, the Cursor is asked for the index of the DISPLAY_NAME_PRIMARY column. But how? If the cursor contains only rows from the "Id" column.
And what does the query method ask for?
Please correct me where I am wrong.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Lebedev, 2015-05-18
@KnightForce

query is a select for a table.
(3) everything is correct
(4) correct, we get the id of a certain record in the table. In fact, just one.
(5) we compose a Uri, by which we can get a specific record through the ContentResolver. Not to a column, but to the record that was found in the previous step.
(1) A Cursor is requested containing not a column with "_id", but a select from the table for those records whose "_id" is equal to the passed one.
(2) A Cursor with just one record that has all columns, from which we scoop out a specific value wat
so wat

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question