简体   繁体   English

如何获取原始文件夹android中的文件路径

[英]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 . getResources().openRawResource(R.raw.zipfile)很好,给你一个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.而且,一般来说,在对象上调用String.valueOf()toString()是为了获取一些开发人员可读的字符串。 The string representation of an InputStream is not going to be a filesystem path. InputStream的字符串表示不会是文件系统路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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