Stay organized with collections
Save and categorize content based on your preferences.
AssetsProvider
interface 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 |
open AssetFileDescriptor? |
Callback that allows the value of a file-based resources or asset to be specified or overridden.
|
Public methods
loadAssetFd
open fun loadAssetFd(
path: String,
accessMode: Int
): AssetFileDescriptor?
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:
- AssetManager is queried for an InputStream of an asset using APIs like android.content.res.AssetManager#open and android.content.res.AssetManager#openXmlResourceParser.
- AssetManager is resolving the value of a file-based resource provided by the
ResourcesProvider
this instance is associated with.
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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# AssetsProvider\n\nAdded in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nAssetsProvider\n==============\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/content/res/loader/AssetsProvider \"View this page in Java\") \n\n```\ninterface AssetsProvider\n```\n\n|------------------------------------------------|\n| [android.content.res.loader.AssetsProvider](#) |\n\nProvides callbacks that allow for the value of a file-based resources or assets of a [ResourcesProvider](/reference/kotlin/android/content/res/loader/ResourcesProvider) to be specified or overridden.\n\nSummary\n-------\n\n| Public methods ||\n|-----------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| open [AssetFileDescriptor](../AssetFileDescriptor.html#)? | [loadAssetFd](#loadAssetFd(kotlin.String,%20kotlin.Int))`(`path:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, `accessMode:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` 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](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun loadAssetFd(\n path: String, \n accessMode: Int\n): AssetFileDescriptor?\n```\n\nCallback that allows the value of a file-based resources or asset to be specified or overridden.\n\nThe system will take ownership of the file descriptor returned from this method, so [dup](../../../os/ParcelFileDescriptor.html#dup()) the file descriptor before returning if the system should 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 android.content.res.AssetManager#open and android.content.res.AssetManager#openXmlResourceParser.\n- AssetManager is resolving the value of a file-based resource provided by the [ResourcesProvider](/reference/kotlin/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 file-based resource or asset within the APK provided by the ResourcesProvider this instance is associated with.\n\n| Parameters ||\n|--------------|--------------------------------------------------------------------------------------------------------------------------------------------|\n| `path` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html): the asset path being loaded This value cannot be `null`. |\n| `accessMode` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): the [AssetManager](../AssetManager.html#) access mode |\n\n**See Also**"]]