Stay organized with collections
Save and categorize content based on your preferences.
AssetsProvider
public
interface
AssetsProvider
android.content.res.loader.AssetsProvider
|
Provides callbacks that allow for the value of a file-based resources or assets of a
ResourcesProvider
to be specified or overridden.
Summary
Public methods |
default
AssetFileDescriptor
|
loadAssetFd(String path, int accessMode)
Callback that allows the value of a file-based resources or asset to be specified or
overridden.
|
Public methods
loadAssetFd
public AssetFileDescriptor loadAssetFd (String path,
int accessMode)
Callback that allows the value of a file-based resources or asset to be specified or
overridden.
The system will take ownership of the file descriptor returned from this method, so
dup
the file descriptor before returning if the system
should not own it.
There are two situations in which this method will be called:
If the value retrieved from this callback is null, AssetManager will attempt to find the
file-based resource or asset within the APK provided by the ResourcesProvider this instance
is associated with.
Parameters |
path |
String : the asset path being loaded
This value cannot be null . |
accessMode |
int : the AssetManager access mode |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# AssetsProvider\n\nAdded in [API level 30](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\nAssetsProvider\n==============\n\n*** ** * ** ***\n\n[Kotlin](/reference/kotlin/android/content/res/loader/AssetsProvider \"View this page in Kotlin\") \\|Java\n\n\n`\npublic\n\n\ninterface\nAssetsProvider\n`\n\n\n`\n\n\n`\n\n|-------------------------------------------|\n| android.content.res.loader.AssetsProvider |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nProvides callbacks that allow for the value of a file-based resources or assets of a\n[ResourcesProvider](/reference/android/content/res/loader/ResourcesProvider) to be specified or overridden.\n\nSummary\n-------\n\n| ### Public methods ||\n|--------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` default `[AssetFileDescriptor](/reference/android/content/res/AssetFileDescriptor) | ` `[loadAssetFd](/reference/android/content/res/loader/AssetsProvider#loadAssetFd(java.lang.String,%20int))`(`[String](/reference/java/lang/String)` path, int accessMode) ` Callback that allows the value of a file-based resources or asset to be specified or overridden. |\n\nPublic methods\n--------------\n\n### loadAssetFd\n\nAdded in [API level 30](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic AssetFileDescriptor loadAssetFd (String path, \n int accessMode)\n```\n\nCallback that allows the value of a file-based resources or asset to be specified or\noverridden.\n\nThe system will take ownership of the file descriptor returned from this method, so\n[dup](/reference/android/os/ParcelFileDescriptor#dup()) the file descriptor before returning if the system\nshould not own it.\n\nThere are two situations in which this method will be called:\n\n- AssetManager is queried for an InputStream of an asset using APIs like [AssetManager.open](/reference/android/content/res/AssetManager#open(java.lang.String)) and [AssetManager.openXmlResourceParser](/reference/android/content/res/AssetManager#openXmlResourceParser(int,%20java.lang.String)).\n- AssetManager is resolving the value of a file-based resource provided by the [ResourcesProvider](/reference/android/content/res/loader/ResourcesProvider) this instance is associated with.\n\nIf the value retrieved from this callback is null, AssetManager will attempt to find the\nfile-based resource or asset within the APK provided by the ResourcesProvider this instance\nis associated with.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|--------------|-------------------------------------------------------------------------------------------|\n| `path` | `String`: the asset path being loaded This value cannot be `null`. \u003cbr /\u003e |\n| `accessMode` | `int`: the [AssetManager](/reference/android/content/res/AssetManager) access mode \u003cbr /\u003e |\n\n| Returns ||\n|---------------------------------------------------------------------------|--------|\n| [AssetFileDescriptor](/reference/android/content/res/AssetFileDescriptor) | \u003cbr /\u003e |\n\n**See also:**\n\n- [AssetManager.open(String)](/reference/android/content/res/AssetManager#open(java.lang.String))"]]