Skip to content

Most visited

Recently visited

navigation

Asset

Files

file  asset_manager.h
 
file  asset_manager_jni.h
 

Typedefs

typedef struct AAssetManager AAssetManager
 
typedef struct AAssetDir AAssetDir
 
typedef struct AAsset AAsset
 

Enumerations

enum  { AASSET_MODE_UNKNOWN = 0, AASSET_MODE_RANDOM = 1, AASSET_MODE_STREAMING = 2, AASSET_MODE_BUFFER = 3 }
 

Functions

AAssetDirAAssetManager_openDir (AAssetManager *mgr, const char *dirName)
 
AAssetAAssetManager_open (AAssetManager *mgr, const char *filename, int mode)
 
const char * AAssetDir_getNextFileName (AAssetDir *assetDir)
 
void AAssetDir_rewind (AAssetDir *assetDir)
 
void AAssetDir_close (AAssetDir *assetDir)
 
int AAsset_read (AAsset *asset, void *buf, size_t count)
 
off_t AAsset_seek (AAsset *asset, off_t offset, int whence) __RENAME_IF_FILE_OFFSET64(AAsset_seek64)
 
off64_t AAsset_seek64 (AAsset *asset, off64_t offset, int whence)
 
void AAsset_close (AAsset *asset)
 
const void * AAsset_getBuffer (AAsset *asset)
 
off_t AAsset_getLength (AAsset *asset) __RENAME_IF_FILE_OFFSET64(AAsset_getLength64)
 
off64_t AAsset_getLength64 (AAsset *asset)
 
off_t AAsset_getRemainingLength (AAsset *asset) __RENAME_IF_FILE_OFFSET64(AAsset_getRemainingLength64)
 
off64_t AAsset_getRemainingLength64 (AAsset *asset)
 
int AAsset_openFileDescriptor (AAsset *asset, off_t *outStart, off_t *outLength) __RENAME_IF_FILE_OFFSET64(AAsset_openFileDescriptor64)
 
int AAsset_openFileDescriptor64 (AAsset *asset, off64_t *outStart, off64_t *outLength)
 
int AAsset_isAllocated (AAsset *asset)
 
AAssetManagerAAssetManager_fromJava (JNIEnv *env, jobject assetManager)
 

Detailed Description

Typedef Documentation

§ AAsset

typedef struct AAsset AAsset

AAsset provides access to a read-only asset.

AAsset objects are NOT thread-safe, and should not be shared across threads.

§ AAssetDir

typedef struct AAssetDir AAssetDir

AAssetDir provides access to a chunk of the asset hierarchy as if it were a single directory. The contents are populated by the AAssetManager.

The list of files will be sorted in ascending order by ASCII value.

§ AAssetManager

typedef struct AAssetManager AAssetManager

AAssetManager provides access to an application's raw assets by creating AAsset objects.

AAssetManager is a wrapper to the low-level native implementation of the java AAssetManager, a pointer can be obtained using AAssetManager_fromJava().

The asset hierarchy may be examined like a filesystem, using AAssetDir objects to peruse a single directory.

A native AAssetManager pointer may be shared across multiple threads.

Enumeration Type Documentation

§ anonymous enum

anonymous enum

Available access modes for opening assets with AAssetManager_open

Enumerator
AASSET_MODE_UNKNOWN 

No specific information about how data will be accessed.

AASSET_MODE_RANDOM 

Read chunks, and seek forward and backward.

AASSET_MODE_STREAMING 

Read sequentially, with an occasional forward seek.

AASSET_MODE_BUFFER 

Caller plans to ask for a read-only buffer with all data.

Function Documentation

§ AAsset_close()

void AAsset_close ( AAsset asset)

Close the asset, freeing all associated resources.

§ AAsset_getBuffer()

const void* AAsset_getBuffer ( AAsset asset)

Get a pointer to a buffer holding the entire contents of the assset.

Returns NULL on failure.

§ AAsset_getLength()

off_t AAsset_getLength ( AAsset asset)

Report the total size of the asset data.

§ AAsset_getLength64()

off64_t AAsset_getLength64 ( AAsset asset)

Report the total size of the asset data. Reports the size using a 64-bit number insted of 32-bit as AAsset_getLength.

§ AAsset_getRemainingLength()

off_t AAsset_getRemainingLength ( AAsset asset)

Report the total amount of asset data that can be read from the current position.

§ AAsset_getRemainingLength64()

off64_t AAsset_getRemainingLength64 ( AAsset asset)

Report the total amount of asset data that can be read from the current position.

Uses a 64-bit number instead of a 32-bit number as AAsset_getRemainingLength does.

§ AAsset_isAllocated()

int AAsset_isAllocated ( AAsset asset)

Returns whether this asset's internal buffer is allocated in ordinary RAM (i.e. not mmapped).

§ AAsset_openFileDescriptor()

int AAsset_openFileDescriptor ( AAsset asset,
off_t *  outStart,
off_t *  outLength 
)

Open a new file descriptor that can be used to read the asset data. If the start or length cannot be represented by a 32-bit number, it will be truncated. If the file is large, use AAsset_openFileDescriptor64 instead.

Returns < 0 if direct fd access is not possible (for example, if the asset is compressed).

§ AAsset_openFileDescriptor64()

int AAsset_openFileDescriptor64 ( AAsset asset,
off64_t *  outStart,
off64_t *  outLength 
)

Open a new file descriptor that can be used to read the asset data.

Uses a 64-bit number for the offset and length instead of 32-bit instead of as AAsset_openFileDescriptor does.

Returns < 0 if direct fd access is not possible (for example, if the asset is compressed).

§ AAsset_read()

int AAsset_read ( AAsset asset,
void *  buf,
size_t  count 
)

Attempt to read 'count' bytes of data from the current offset.

Returns the number of bytes read, zero on EOF, or < 0 on error.

§ AAsset_seek()

off_t AAsset_seek ( AAsset asset,
off_t  offset,
int  whence 
)

Seek to the specified offset within the asset data. 'whence' uses the same constants as lseek()/fseek().

Returns the new position on success, or (off_t) -1 on error.

§ AAsset_seek64()

off64_t AAsset_seek64 ( AAsset asset,
off64_t  offset,
int  whence 
)

Seek to the specified offset within the asset data. 'whence' uses the same constants as lseek()/fseek().

Uses 64-bit data type for large files as opposed to the 32-bit type used by AAsset_seek.

Returns the new position on success, or (off64_t) -1 on error.

§ AAssetDir_close()

void AAssetDir_close ( AAssetDir assetDir)

Close an opened AAssetDir, freeing any related resources.

§ AAssetDir_getNextFileName()

const char* AAssetDir_getNextFileName ( AAssetDir assetDir)

Iterate over the files in an asset directory. A NULL string is returned when all the file names have been returned.

The returned file name is suitable for passing to AAssetManager_open().

The string returned here is owned by the AssetDir implementation and is not guaranteed to remain valid if any other calls are made on this AAssetDir instance.

§ AAssetDir_rewind()

void AAssetDir_rewind ( AAssetDir assetDir)

Reset the iteration state of AAssetDir_getNextFileName() to the beginning.

§ AAssetManager_fromJava()

AAssetManager* AAssetManager_fromJava ( JNIEnv *  env,
jobject  assetManager 
)

Given a Dalvik AssetManager object, obtain the corresponding native AAssetManager object. Note that the caller is responsible for obtaining and holding a VM reference to the jobject to prevent its being garbage collected while the native object is in use.

§ AAssetManager_open()

AAsset* AAssetManager_open ( AAssetManager mgr,
const char *  filename,
int  mode 
)

Open an asset.

The object returned here should be freed by calling AAsset_close().

§ AAssetManager_openDir()

AAssetDir* AAssetManager_openDir ( AAssetManager mgr,
const char *  dirName 
)

Open the named directory within the asset hierarchy. The directory can then be inspected with the AAssetDir functions. To open the top-level directory, pass in "" as the dirName.

The object returned here should be freed by calling AAssetDir_close().

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Follow Google Developers on WeChat

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience.
(Sep 2017 survey)