How to access assets folder in my android app?

吃可爱长大的小学妹 提交于 2019-12-01 06:49:13
Avezou

Zip your xml folder (xml.zip for example) and put it in assets. Getting assets with AssetsManager is very slow. Also, doing so you can maintain your directory structure and just copy it to sdcard and extract it there. This will be a lot faster than getting each file in the directory. You can use this post for the unzipping: How to unzip files programmatically in Android?. Hope this helps.

Assets should be in the root of the folder... cannot put file in a sub folder. assets\file.suf would work while assets\sub\file.suf would not

android.resource://packagename/assets/filename

you can use the above line to refer to a file in assets folder. Just replace the package name and file name.

Note file name must not contain extensions

Updated::

private List<String> getFiles(){
 AssetManager assetManager = getAssets();
    List<String> files = null;
    try {
        files = assetManager.list("");
    } catch (IOException e) {
        Log.e("tag", e.getMessage());
    }
} 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!