Raw folder url path?

How can I get the URL of the raw folder? I do not want to access my asset via id but by path instead.


Solution 1:

Uri video = Uri.parse("android.resource://com.cpt.sample/raw/filename");

Using this you can access the file in raw folder, if you want to access the file in asset folder use this URL...

file:///android_asset/filename

Make sure you don't add the extension to the filename. E.g. "/movie" not "/movie.mp4".

Solution 2:

This is to find a file named video.mp4 inside raw folder:

    String path = "android.resource://" + getPackageName() + "/" + R.raw.video;

Solution 3:

Now u can do this:

getResources().openRawResource(R.raw.filename)

Solution 4:

The point with using raw is to access with the id, for example R.raw.your_object_id. If you want to access to your resources with file path then you need to use assets.

Then you can use assets like this:

InputStream myInput = myContext.getAssets().open("MyFolder/" + "MyFile.db3");
InputStream myInpu1t = myContext.getAssets().open("MyFile_in_the_root.db3");