Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting File from /res/raw

Tags:

android

I need your help, may be this question is very easy for you. I have a file in /res/raw folder. For example, it's id is R.raw.myFile. I need to get "File" object. Such as i can do with file on 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.

like image 837
pavelkorolevxyz Avatar asked Jan 11 '11 15:01

pavelkorolevxyz


People also ask

Where is res raw folder Android?

The raw folder is created inside the res folder: main/res/raw.

How can I view RAW files on Android?

Open the Camera app. Tap the settings gear in the top left corner. Go to Format and advanced options. Turn the RAW copies toggle on.

How to read data from raw folder in Android?

Put files to your package's res/raw folder. Use the getResources() method from the Activity class to return a Resources object. Use its openRawResource() method to open the file contained in the res/raw folder.


1 Answers

Use this

InputStream inputStream = getResources().openRawResource(R.raw.filename);
like image 69
Labeeb Panampullan Avatar answered Oct 05 '22 06:10

Labeeb Panampullan