Reputation: 2247
My Android game has an install-time asset pack with all the graphics in it. This isn't stored stored in my app's primary package so I can't access it with getPackageResourcePath(). Is there some other function that would allow me to get the asset package in the same way?
Upvotes: 0
Views: 79
Reputation: 2247
I found the solution for what I was trying to do.
// Get path to play store assets
val pkgInfo = packageManager.getPackageInfo("com.mycompany.mygame", 0)
var playAssetsPath = ""
val splitNames = pkgInfo.splitNames
for (idx in 0..splitNames.size - 1) {
if (splitNames[idx] == "play_assets") {
val splitsPaths = pkgInfo.applicationInfo?.splitSourceDirs
playAssetsPath = splitsPaths!![idx]
}
}
Log.e(LOGTAG, "playAssetsPath = $playAssetsPath")
With this full APK path I can access my assets without relying upon AssetManager's clunky streaming mechanism, which doesn't recognize directory structures.
Upvotes: 0