public class AssetsExtractor
extends java.lang.Object
Call extractAssets()
to unpack resources to local storage. Android uses special
assets URI and storage inside the generated AARs and APKs Assets are logically located inside
src/xxx/assets folder in any Android project. These assets are then compressed and packaged
inside the resulting AAR/APK. They can't be accessed through standard Java IO methods, AssetManager
is the only way to access them.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DATA_SUBPATH |
Constructor and Description |
---|
AssetsExtractor(android.content.Context context) |
Modifier and Type | Method and Description |
---|---|
java.io.File |
extractAssets()
Extracts all assets into app-specific data directory.
|
java.io.File |
extractAssets(boolean force)
Extracts all assets into app-specific data directory.
|
void |
extractAssets(java.lang.String assetSrc,
java.io.File target)
Extracts assets using
AssetManager , recreating the same structure as in there inside
local filesystem. |
public static final java.lang.String DATA_SUBPATH
public java.io.File extractAssets(boolean force)
If assets for current SDK version are already extracted the process is skipped.
App-specific data directory is usually /data/data/app.package.name/files
dir.
force
- if true, always extracts assets without version checkpublic java.io.File extractAssets()
extractAssets(boolean)
public void extractAssets(java.lang.String assetSrc, java.io.File target)
AssetManager
, recreating the same structure as in there inside
local filesystem. You should have an ability to create files and folders in target.assetSrc
- root of asset tree to copy fromtarget
- target dir to recreate asset directory structure, or target file if source
asset is a file