我已将一堆波形文件添加到我的资产目录中以进行加载。
我通过右键单击android中的res文件夹创建了资产,然后去了#34;添加文件夹 - >资产文件夹"
它在app \ src \ main \ assets。
创建了一个资产文件夹我已将一堆wav文件拖到该资产目录中。
但是,当我列出资产目录中的所有文件时,它只列出一个名为" images"的单个目录。
请注意以下代码。有一条消息写入只能写出"图像"。
AssetManager assets = LocalApp.getAppContext().getAssets();
String[] fileList = assets.list("");
// we assume all the files in the assets are the wav files that we want to load,
// so attempt to load everythign in assets as a wav
for (int i = 0; i < fileList.length; i++) {
Log.e(TAG, "readSamples: file name = "+fileList[i]);
WavFile wave = new WavFile(assets.open(fileList[i]));
samples.add(wave);
}
答案 0 :(得分:-1)
也许你可以试试这个: -
String dirFrom = "putYourPathToAssestsFolderHere"
//if you are in an activity
Resources res = getResources();
AssetManager assets = res.getAssets();
String fileList[] = assets.list(dirFrom);
if (fileList != null)
{
for ( int i = 0;i<fileList.length;i++)
{
Log.e(TAG, "readSamples: file name = "+fileList[i]);
}
}