android.content.res
public
final
class
android.content.res.AssetManager
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.
Nested Classes
Summary
Constants
Public Methods
Protected Methods
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait
Details
Constants
public
static
final
int
ACCESS_BUFFER
Mode for
open(String, int): Attempt to load contents into
memory, for fast small reads.
Constant Value:
3
(0x00000003)
public
static
final
int
ACCESS_RANDOM
Mode for
open(String, int): Read chunks, and seek forward and
backward.
Constant Value:
1
(0x00000001)
public
static
final
int
ACCESS_STREAMING
Mode for
open(String, int): Read sequentially, with an
occasional forward seek.
Constant Value:
2
(0x00000002)
public
static
final
int
ACCESS_UNKNOWN
Mode for
open(String, int): no specific information about how
data will be accessed.
Constant Value:
0
(0x00000000)
Public Methods
public
void
close()
Close this asset manager.
public
final
String[]
getLocales()
Get the locales that this asset manager contains data for.
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().
public
final
InputStream
open(String fileName, int accessMode)
Open an asset using an explicit access mode, returning an InputStream to
read its contents. 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. |
accessMode
| Desired access mode for retrieving the data. |
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. |
Retrieve a parser for a compiled XML file.
Parameters
fileName
| The name of the file to retrieve.
|
public
final
XmlResourceParser
openXmlResourceParser(int cookie, String fileName)
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.
|
Protected Methods
protected
void
finalize()
Called by the virtual machine when there are no longer any (non-weak)
references to the receiver. Subclasses can use this facility to guarantee
that any associated resources are cleaned up before the receiver is
garbage collected. Uncaught exceptions which are thrown during the
running of the method cause it to terminate immediately, but are
otherwise ignored.
Note: The virtual machine assumes that the implementation in class Object
is empty.