如何获取原始文件夹android中的文件路径 [英] how to get path of file in raw folder android

查看:73
本文介绍了如何获取原始文件夹android中的文件路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I need the String Address of the raw folder directory this is my code but it ends with crash

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) 很好,给你一个 InputStream.用它来读入你的资源内容.

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

而且,一般来说,在对象上调用 String.valueOf()toString() 是为了获取一些开发人员可读的字符串.InputStream 的字符串表示不会是文件系统路径.

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.

这篇关于如何获取原始文件夹android中的文件路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆