List of files in assets folder and its subfolders

后端 未结 6 1052
甜味超标
甜味超标 2020-11-27 15:00

I have some folders with HTML files in the \"assets\" folder in my Android project. I need to show these HTML files from assets\' sub-folders in a list. I already wrote some

6条回答
  •  爱一瞬间的悲伤
    2020-11-27 15:44

    try this it will work in your case

    f = getAssets().list("");
    for(String f1 : f){
        Log.v("names",f1);
    }
    

    The above snippet will show the contents of the asset root.

    For example... if below is the asset structure..

    assets
     |__Dir1
     |__Dir2
     |__File1
    

    Snippet's output will be .... Dir1 Dir2 File1

    If you need the contents of the Directory Dir1

    Pass the name of Directory in the list function.

      f = getAssets().list("Dir1");
    

提交回复
热议问题