问题描述
我的内容类型非常基本的理解问题。
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 problem. Can some clarify me please.
在android的记事本的例子,和许多人一样,它被提及vnd.android.cursor.dir /解析为项目列表中的目录和vnd.android.cursor.item /指的是具体的项目目录中。
In the android notepad example, and many others, it is mentioned vnd.android.cursor.dir/ resolves to a list of items in a directory and vnd.android.cursor.item/ refers to specific item in a directory.
这是vnd.android.cursor.dir搭载Android定义一些标准不变。哪里这个来自?或者我可以改变它像
Is this vnd.android.cursor.dir some standard constant defined by android. Where did this come from?, or can i change it like
vn.com.android.myexample.dir /
这是怎么回事,甚至解决,其目的是什么,为什么不使用完整CONTENT_URI?
vn.com.android.myexample.dir/
How is this even resolved and what is its purpose, why not use the full CONTENT_URI?
对不起,我完全迷失了,不明白这一点。
Sorry, i'm totally lost, and don't understand this.
推荐答案
由ContentProvider.getType返回的MIME类型有两个截然不同的部分:
The MIME types returned by ContentProvider.getType have two distinct parts:
type/subType
类型部分指示被返回以用于由ContentProvider的一个给定URI的公知的类型,作为查询方法只能返回光标的类型应始终是:
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..x 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.
因此,使用ContentProvider的时候,你可以自定义MIME类型的第二子类型部分,但不是第一个部分。例如,一个有效的MIME类型为您的应用程序的ContentProvider可以是:
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
这ContentProvider的返回的MIME类型可以由一个意向确定启动处理来自一个给定URI检索到的数据,活动
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.
这篇关于Android的内容类型 - 是vnd.android.cursor.dir搭载Android定义一些标准定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!