Class AssetUtils

java.lang.Object
com.massifmaps.utils.AssetUtils

public class AssetUtils extends Object
A helper class for managing application-bundled assets.
  • 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

      public static BinaryData loadAsset(String path)
      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

      public static boolean assetExists(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.
      Parameters:
      path - The path of the asset, relative to the application root folder.
      Returns:
      True if the asset exists as a file.
    • listAssets

      public static StringVector listAssets(String path)
      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.