Tag: 资产

如何获取Android Path字符串到资产文件夹上的文件?

我需要知道资产文件夹上的文件的字符串路径 ,因为我使用的地图api需要接收一个字符串路径,我的地图必须存储在资产文件夹 这是我正在尝试的代码: MapView mapView = new MapView(this); mapView.setClickable(true); mapView.setBuiltInZoomControls(true); mapView.setMapFile("file:///android_asset/m1.map"); setContentView(mapView); "file:///android_asset/m1.map"有些问题,因为地图没有被加载。 这是正确的字符串路径文件存储在我的资产文件夹文件m1.map? 谢谢 编辑Dimitru:此代码不起作用,它在is.read(buffer);失败is.read(buffer); 与IOException try { InputStream is = getAssets().open("m1.map"); int size = is.available(); byte[] buffer = new byte[size]; is.read(buffer); is.close(); text = new String(buffer); } catch (IOException e) {throw new RuntimeException(e);}