Why doesn't the subtype of this custom MIME type specify the particular row (from Content URI) in the table?

284 views Asked by At

AT the end of the developer guide, they have described vnd.android.cursor.dir to be the type part of every custom MIME type, for multiple rows; and vnd.android.cursor.item for a single row.

Then there is an example of a Content Provider that contains train timetables. It's authority is com.example.trains and it has tables Line1, Line2, and Line3. And for it's content URI

content://com.example.trains/Line2/5

which is obviously pointing to the "5th row in the Line2 table", the MIME type returned will be:

vnd.android.cursor.item/vnd.example.line2

which does not indicate which row it is.

QUESTIONS:

  1. I think it should be something like:

    vnd.android.cursor.item/vnd.example.line2.5
    

    because the type part does describe that it is the MIME type for a particular row, so the subtype should also describe which row it is. Isn't it?

  2. If vnd.android.cursor.item/vnd.example.line2 is correct, then that means it does not matter if the MIME type is of a particular row. Does it mean all the rows in a table have the same MIME type? Because a MIME type is simply the type of files on the internet. (Reference) So I think since all the rows have the same "types" of data (or in other words the rows in a table are kinda instances of the same thing) - so I think all rows in a table should inherently have the same MIME type?

  3. If ^ is YES, then what is the point of having the categorization into the vnd.android.cursor.dir and vnd.android.cursor.item ?

1

There are 1 answers

0
CommonsWare On BEST ANSWER

I think it should be something like:

vnd.android.cursor.item/vnd.example.line2.5

because the type part does describe that it is the MIME type for a particular row, so the subtype should also describe which row it is. Isn't it?

No, no more than the MIME type for this Web page is text/html.30821182 because it happens to be question #30821182 on this Web site. MIME types in Android represent data formats.

Does it mean all the rows in a table have the same MIME type?

In that provider, yes.

Because a MIME type is simply the type of files on the internet.

Android stretches the definition of a MIME type to be more generic than just files. In the case of the database-style API of a ContentProvider, the MIME type is mostly there to link the data structure for a Uri with an activity that can work with that data structure.

I think all rows in a table should inherently have the same MIME type?

That is the typical pattern for the database-style ContentProvider API.

then what is the point of having the categorization into the vnd.android.cursor.dir and vnd.android.cursor.item ?

The former represents a collection of content, what you would think of as a table or view in a SQL database. The latter represents an instance of content, what you would think of as a row in a table or view in a SQL database.