[英]Android Assets - Unable to access
使用此代碼,它應該返回資產列表。 但是它崩潰了,當我調用list方法時,在調試器中顯示“找不到源,編輯源查找路徑...”消息:
@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) {
}
}
使用此代替:
String[] arr = getAssets().list("");
嘗試將路徑傳遞給AssetManager#list(String)
而不是null
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.