2012年11月5日月曜日

openAssetFileDescriptor

Open a raw file descriptor to access data under a URI. This interacts with the underlying openAssetFile(Uri, String) method of the provider associated with the given URI, to retrieve any file stored there.

Accepts the following URI schemes:
The android.resource (SCHEME_ANDROID_RESOURCE) Scheme

A Uri object can be used to reference a resource in an APK file. The Uri should be one of the following formats:

  • android.resource://package_name/id_number
    package_name is your package name as listed in your AndroidManifest.xml. For example com.example.myapp
    id_number is the int form of the ID.
    The easiest way to construct this form is
    Uri uri = Uri.parse("android.resource://com.example.myapp/" + R.raw.my_resource");
  • android.resource://package_name/type/name
    package_name is your package name as listed in your AndroidManifest.xml. For example com.example.myapp
    type is the string form of the resource type. For example, raw or drawable. name is the string form of the resource name. That is, whatever the file name was in your res directory, without the type extension. The easiest way to construct this form is
    Uri uri = Uri.parse("android.resource://com.example.myapp/raw/my_resource");

Note that if this function is called for read-only input (mode is "r") on a content: URI, it will instead callopenTypedAssetFileDescriptor(Uri, String, Bundle) for you with a MIME type of "*\/*". This allows such callers to benefit from any built-in data conversion that a provider implements.

0 件のコメント:

コメントを投稿