Why is AssetManger.list() so slow?

后端 未结 4 790
遥遥无期
遥遥无期 2021-01-18 03:25

I\'m trying to populate a ListView with a mixture of files stored on the SDcard AND stored as assets in the APK. Using TraceView, I can see that the performanc

4条回答
  •  無奈伤痛
    2021-01-18 04:13

    Can anyone explain why the performance would be so poor?

    Reading the contents of a ZIP archive (the APK where the assets are located) is slower than reading the contents of a directory on the filesystem, apparently. In the abstract, this is not especially surprising, as I suspect that this would be true for all major operating systems.

    Read in that list() data once, then save it somewhere else for faster access (e.g., database), particularly in a form that is optimized for future lookups (e.g., where a simple database query could give you what you want, vs. having to load and "recursively search it" again).

提交回复
热议问题