This singleton class handles file access to APK assets. More...
Classes | |
class | ResourceFile |
Resource File. More... | |
Public Member Functions | |
void | APKCloseFile (ResourceFile file) |
Closes the input stream in given ResourceFile and releases associated resources. More... | |
long | APKGetFileLength (ResourceFile file) |
Returns the total number of bytes of ResourceFile's data. More... | |
ResourceFile | APKOpenFile (String filename) |
Creates a ResourceFile object containing an open InputStream for the given filename in context set by setContext(Context). More... | |
long | APKReadFile (ResourceFile file, int size) |
Reads the specified number of bytes from a given ResourceFile. More... | |
long | APKSkipFile (ResourceFile file, int offset) |
Skips over and discards a number bytes of data from ResourceFile's input stream. More... | |
Context | getContext () |
Returns the context which have been set using setContext(Context). More... | |
void | setContext (Context context) |
Sets the context of KanziResourceFile. More... | |
Static Public Member Functions | |
static KanziResourceFile | getInstance () |
Returns an instance of KanziResourceFile. More... | |
This singleton class handles file access to APK assets.
void APKCloseFile | ( | ResourceFile | file | ) |
Closes the input stream in given ResourceFile and releases associated resources.
file | ResourceFile to close. |
long APKGetFileLength | ( | ResourceFile | file | ) |
Returns the total number of bytes of ResourceFile's data.
May be AssetFileDescriptor#UNKNOWN_LENGTH if the asset extends to the end of the file.
file | ResourceFile to query. |
ResourceFile APKOpenFile | ( | String | filename | ) |
Creates a ResourceFile object containing an open InputStream for the given filename in context set by setContext(Context).
filename | A resource file in APK to be opened. |
long APKReadFile | ( | ResourceFile | file, |
int | size | ||
) |
Reads the specified number of bytes from a given ResourceFile.
Reallocates the byte buffer in ResourceFile to
bytes, if requested size is larger than the previously allocated size of ResourceFile.
file | ResourceFile with open InputStream to read. |
size | Read buffer size in bytes. |
long APKSkipFile | ( | ResourceFile | file, |
int | offset | ||
) |
Skips over and discards a number bytes of data from ResourceFile's input stream.
The skip method may, for a variety of reasons, end up skipping over some smaller number of bytes, possibly 0. The actual number of bytes skipped is returned. If offset is negative, this method returns 0, and no bytes are skipped.
file | ResourceFile to read. |
offset | Number of bytes to skip. |
Context getContext | ( | ) |
Returns the context which have been set using setContext(Context).
|
static |
Returns an instance of KanziResourceFile.
Before using the returned instance for the first time, context has to be set once using setContext(Context). Context defaults to null and APKOpenFile(String) requests will fail until set.
void setContext | ( | Context | context | ) |
Sets the context of KanziResourceFile.
context | The application's context utilizing KanziResourceFile's services. |