简体   繁体   English

从/ res / raw获取文件

[英]Getting File from /res/raw

I need your help, may be this question is very easy for you. 我需要你的帮助,可能这个问题对你来说很容易。 I have a file in /res/raw folder. 我在/ res / raw文件夹中有一个文件。 For example, it's id is R.raw.myFile . 例如,它的id是R.raw.myFile I need to get "File" object. 我需要获取“文件”对象。 Such as i can do with file on sdcard 比如我可以用sdcard上的文件做

File file = new File("/sdcard/myFolder/myFile");

How I can do this? 我怎么能这样做?

By the way, sorry for my english if there are some mistakes. 顺便说一句,如果有一些错误,请为我的英语道歉。

I need "File" object. 我需要“文件”对象。 Not stream. 不流。

用这个

InputStream inputStream = getResources().openRawResource(R.raw.filename);

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

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