My application has an assets directory in which I've dumped a bunch of text files I need to load at runtime.
I have a directory full of assets of a particular type (i.e., "assets/subdir") and I want to load all of the files in this directory, one at a time.
I have code like this:
AssetManager assetMgr = getAssets();
String[] assetsIWant = assetMgr.list("subdir");
for(String asset: assetsIWant) {
doAssetyThing(asset);
}
I've tried a zillion different versions of the parameter to assetMgr.list() and am not getting anywhere.
If I use "/", I get back a list containing the "assets" directory, and a few random other items (META_INF, for example). If I pass any other string (like "assets" or "assets/" or "/assets" or "/assets/" or "mysubdir" or "/mysubdir" or "assets/mysubdir" or ...) then I get back an empty array.
The documentation is unfortunately fairly incoherent.
Does anybody know what the correct formula for that list() parameter is?
I'm not sure why it works this way, but when I list
"/", I get root level stuff, not things from my"assets"directory. I actually found no way to properly list my assets folder in the short time I spent trying.The workaround I'm using is to create a
"subdir"directory inside of my"assets"directory. I put all the assets that I want to access in this"subdir", and do:String[] assetsIWant = assetMgr.list("subdir");I don't know why
"/"lists the"assets"directory itself as one of it's files, yet you don't have to specify the"assets"directory when givinglista path. Maybe someone else knows, but I hope this tip will help you out anyway.