使用此代码,它应返回资产列表。但是当我调用list方法时,调试器中出现“Source not found,Edit Source Lookup Path ...”消息时崩溃了:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
AssetManager assets = this.getAssets();
try {
//error happens on this next line
String[] l = assets.list(null);
} catch (IOException e) {
}
}
答案 0 :(得分:2)
请改用:
String[] arr = getAssets().list("");
答案 1 :(得分:1)
尝试将路径传递给AssetManager#list(String)
而不是null
。