Android 资产 - 无法访问
使用此代码,它应该返回资产列表。但当我调用 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) {
}
}
Using this code it should return a list of the assets. But it crashes, with a "Source not found, Edit Source Lookup Path..." message in the debugger when I call the list method:
@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) {
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用这个代替:
Use this instead:
尝试将路径传递给
AssetManager#list(String)
而不是null
。Try passing a path to
AssetManager#list(String)
instead ofnull
.