Package com.massifmaps.utils
Class AssetUtils
java.lang.Object
com.massifmaps.utils.AssetUtils
A helper class for managing application-bundled assets.
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanassetExists(String path) Returns true if the specified bundled asset exists and is a FILE (not a directory).
Unlike loadAsset this does not read or log anything, so it can be used to probe.static StringVectorlistAssets(String path) Lists the names of the assets directly inside the specified bundled directory.static BinaryDataLoads the specified bundled asset.static voidsetAssetManagerPointer(android.content.res.AssetManager androidAssetManager) Internal method for connecting to asset manager.
-
Method Details
-
setAssetManagerPointer
public static void setAssetManagerPointer(android.content.res.AssetManager androidAssetManager) Internal method for connecting to asset manager.- Parameters:
androidAssetManager- The asset manager instance to use.
-
loadAsset
Loads the specified bundled asset.- Parameters:
path- The path of the asset to load. The path is relative to application root folder.- Returns:
- The loaded asset as a byte vector or null if the asset was not found or could not be loaded.
-
assetExists
Returns true if the specified bundled asset exists and is a FILE (not a directory).
Unlike loadAsset this does not read or log anything, so it can be used to probe.- Parameters:
path- The path of the asset, relative to the application root folder.- Returns:
- True if the asset exists as a file.
-
listAssets
Lists the names of the assets directly inside the specified bundled directory. The
listing is NOT recursive and does not tell files and directories apart - an entry is a
directory if listing it returns something, a file if assetExists returns true for it.
Note: the NDK asset API cannot enumerate directories at all, so this goes through the
Java AssetManager; the asset manager must already be connected (a MapView does that).- Parameters:
path- The directory path, relative to the application root folder ("" is the root).- Returns:
- The names of the entries in that directory, without any path prefix.
-