List assets in a subdirectory using AssetManager.list

后端 未结 9 597
梦谈多话
梦谈多话 2020-12-04 23:37

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

9条回答
  •  自闭症患者
    2020-12-05 00:16

    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 giving list a path. Maybe someone else knows, but I hope this tip will help you out anyway.

提交回复
热议问题