文字列パスを受け取る必要があるマップ API を使用しており、マップを assets フォルダーに保存する必要があるため、assets フォルダーにあるファイルへの文字列パスを知る必要があります。
これは私が試しているコードです:
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 の編集: このコードは機能しません。IOException で失敗しますis.read(buffer);
。
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);}