Android 获取assets的绝对路径

 第一种方法:
       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;
    }

注明:QQ技术交流群:108614806   感兴趣的加一下。

原文地址:https://www.cnblogs.com/zhiqiangsimida/p/2774662.html