Android, how do can I get a list of all files in a folder?

后端 未结 6 2044
心在旅途
心在旅途 2020-11-30 02:28

I need the name (String) of all files in res/raw/

I tried:

File f = new File(\"/\"); 
String[] someFiles = f.list();

It looks like

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-30 02:55

    Look at http://developer.android.com/reference/android/content/res/Resources.html You can generally acquire the Resources instance associated with your application with getResources().

    Resources class provides access to http://developer.android.com/reference/android/content/res/AssetManager.html (see to getAssets() method). And finally obtain access to your packaged (apk) files with AssetManager.list() method. Enjoy!

提交回复
热议问题