简体   繁体   中英

how to get path of file in raw folder android

我需要原始文件夹目录的字符串地址,这是我的代码,但它以崩溃结束

private String zipPath = String.valueOf(getResources().openRawResource(R.raw.zipfile));

Resources are files on your development machine. They are not files on the device. There is no path to your raw resource.

getResources().openRawResource(R.raw.zipfile) is fine, to give you an InputStream . Use that to read in your resource contents.

And, in general, calling String.valueOf() or toString() on objects is for getting some developer-readable string. The string representation of an InputStream is not going to be a filesystem path.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM