A. 如何獲得android assert 里圖片的絕對路徑
第一種方法:
String path = "file:///android_asset/文件名";
第二種方法:
InputStream abpath = getClass().getResourceAsStream("/assets/文件名");
若要想要轉換成String類型
String path = new String(InputStreamToByte(abpath ));
private byte[] InputStreamToByte(InputStream is) throws IOException {
ByteArrayOutputStream bytestream = new ByteArrayOutputStream();
int ch;
while ((ch = is.read()) != -1) {
bytestream.write(ch);
}
byte imgdata[] = bytestream.toByteArray();
bytestream.close();
return imgdata;
}