Android CONTENT TYPE - Is vnd.android.cursor.dir some standard constant defined by android?

前端 未结 2 2022
借酒劲吻你
借酒劲吻你 2020-12-13 06:39

I have very basic understanding problem of Content types.

I went through lot of examples and text explaining the above term, but still have some basic understanding

2条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-13 07:09

    Documentation: https://developer.android.com/guide/topics/providers/content-provider-basics#MIMETypeReference

    The MIME types returned by ContentProvider.getType have two distinct parts:

    type/subType
    

    The type portion indicates the well known type that is returned for a given URI by the ContentProvider, as the query methods can only return Cursors the type should always be:

    • vnd.android.cursor.dir for when you expect the Cursor to contain 0 through infinity items

    or

    • vnd.android.cursor.item for when you expect the Cursor to contain 1 item

    The subType portion can be either a well known subtype or something unique to your application.

    So when using a ContentProvider you can customize the second subType portion of the MIME type, but not the first portion. e.g a valid MIME type for your apps ContentProvider could be:

    vnd.android.cursor.dir/vnd.myexample.whatever
    

    The MIME type returned from a ContentProvider can be used by an Intent to determine which activity to launch to handle the data retrieved from a given URI.

提交回复
热议问题