IT. Expert System.

Android Reference

AssetManager


android.content.res

Class AssetManager

  • Direct Known Subclasses:
    BridgeAssetManager


    public final class AssetManager
    extends Object
    Provides access to an application's raw asset files; see Resources for the way most applications will want to retrieve their resource data. This class presents a lower-level API that allows you to open and read raw files that have been bundled with the application as a simple stream of bytes.
    • Constructor Detail

      • AssetManager

        public AssetManager()
        Create a new AssetManager containing only the basic system assets. Applications will not generally use this method, instead retrieving the appropriate asset manager with Resources.getAssets(). Not for use by applications.
    • Method Detail

      • getSystem

        public static AssetManager getSystem()
        Return a global shared asset manager that provides access to only system assets (no application assets).
      • close

        public void close()
        Close this asset manager.
      • open

        public final InputStream open(String fileName)
                               throws IOException
        Open an asset using ACCESS_STREAMING mode. This provides access to files that have been bundled with an application as assets -- that is, files placed in to the "assets" directory.
        Parameters:
        fileName - The name of the asset to open. This name can be hierarchical.
        Throws:
        IOException
        See Also:
        open(String, int), list(java.lang.String)
      • list

        public final String[] list(String path)
                            throws IOException
        Return a String array of all the assets at the given path.
        Parameters:
        path - A relative path within the assets, i.e., "docs/home.html".
        Returns:
        String[] Array of strings, one for each asset. These file names are relative to 'path'. You can open the file by concatenating 'path' and a name in the returned string (via File) and passing that to open().
        Throws:
        IOException
        See Also:
        open(java.lang.String)
      • openNonAsset

        public final InputStream openNonAsset(String fileName)
                                       throws IOException
        Open a non-asset file as an asset using ACCESS_STREAMING mode. This provides direct access to all of the files included in an application package (not only its assets). Applications should not normally use this.
        Throws:
        IOException
        See Also:
        open(String)
      • openNonAsset

        public final InputStream openNonAsset(String fileName,
                               int accessMode)
                                       throws IOException
        Open a non-asset file as an asset using a specific access mode. This provides direct access to all of the files included in an application package (not only its assets). Applications should not normally use this.
        Throws:
        IOException
        See Also:
        open(String, int)
      • openNonAsset

        public final InputStream openNonAsset(int cookie,
                               String fileName)
                                       throws IOException
        Open a non-asset in a specified package. Not for use by applications.
        Parameters:
        cookie - Identifier of the package to be opened.
        fileName - Name of the asset to retrieve.
        Throws:
        IOException
      • openNonAsset

        public final InputStream openNonAsset(int cookie,
                               String fileName,
                               int accessMode)
                                       throws IOException
        Open a non-asset in a specified package. Not for use by applications.
        Parameters:
        cookie - Identifier of the package to be opened.
        fileName - Name of the asset to retrieve.
        accessMode - Desired access mode for retrieving the data.
        Throws:
        IOException
      • openXmlResourceParser

        public final XmlResourceParser openXmlResourceParser(String fileName)
                                                      throws IOException
        Retrieve a parser for a compiled XML file.
        Parameters:
        fileName - The name of the file to retrieve.
        Throws:
        IOException
      • openXmlResourceParser

        public final XmlResourceParser openXmlResourceParser(int cookie,
                                              String fileName)
                                                      throws IOException
        Retrieve a parser for a compiled XML file.
        Parameters:
        cookie - Identifier of the package to be opened.
        fileName - The name of the file to retrieve.
        Throws:
        IOException
      • finalize

        protected void finalize()
                         throws Throwable
        Description copied from class: Object
        Invoked when the garbage collector has detected that this instance is no longer reachable. The default implementation does nothing, but this method can be overridden to free resources.

        Note that objects that override finalize are significantly more expensive than objects that don't. Finalizers may be run a long time after the object is no longer reachable, depending on memory pressure, so it's a bad idea to rely on them for cleanup. Note also that finalizers are run on a single VM-wide finalizer thread, so doing blocking work in a finalizer is a bad idea. A finalizer is usually only necessary for a class that has a native peer and needs to call a native method to destroy that peer. Even then, it's better to provide an explicit close method (and implement Closeable), and insist that callers manually dispose of instances. This works well for something like files, but less well for something like a BigInteger where typical calling code would have to deal with lots of temporaries. Unfortunately, code that creates lots of temporaries is the worst kind of code from the point of view of the single finalizer thread.

        If you must use finalizers, consider at least providing your own ReferenceQueue and having your own thread process that queue.

        Unlike constructors, finalizers are not automatically chained. You are responsible for calling super.finalize() yourself.

        Uncaught exceptions thrown by finalizers are ignored and do not terminate the finalizer thread. See Effective Java Item 7, "Avoid finalizers" for more.

        Overrides:
        finalize in class Object
        Throws:
        Throwable
      • addAssetPath

        public final int addAssetPath(String path)
        Add an additional set of assets to the asset manager. This can be either a directory or ZIP file. Not for use by applications. Returns the cookie of the added asset, or 0 on failure.
      • addAssetPaths

        public final int[] addAssetPaths(String[] paths)
        Add multiple sets of assets to the asset manager at once. See addAssetPath(String) for more information. Returns array of cookies for each added asset with 0 indicating failure, or null if the input array of paths is null.
      • isUpToDate

        public final boolean isUpToDate()
        Determine whether the state in this asset manager is up-to-date with the files on the filesystem. If false is returned, you need to instantiate a new AssetManager class to see the new data.
      • setLocale

        public final void setLocale(String locale)
        Change the locale being used by this asset manager. Not for use by applications.
      • getLocales

        public final String[] getLocales()
        Get the locales that this asset manager contains data for.
      • setConfiguration

        public final void setConfiguration(int mcc,
                            int mnc,
                            String locale,
                            int orientation,
                            int touchscreen,
                            int density,
                            int keyboard,
                            int keyboardHidden,
                            int navigation,
                            int screenWidth,
                            int screenHeight,
                            int smallestScreenWidthDp,
                            int screenWidthDp,
                            int screenHeightDp,
                            int screenLayout,
                            int uiMode,
                            int majorVersion)
        Change the configuation used when retrieving resources. Not for use by applications.
      • getCookieName

        public final String getCookieName(int cookie)
      • getGlobalAssetCount

        public static final int getGlobalAssetCount()
      • getAssetAllocations

        public static final String getAssetAllocations()
      • getGlobalAssetManagerCount

        public static final int getGlobalAssetManagerCount()


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 2269 / 96488068. Delta: 0.05188 с