Raw folder url path?

Android

Android Problem Overview


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

Android Solutions


Solution 1 - Android

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 - Android

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

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

Solution 3 - Android

Now u can do this:

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

Solution 4 - Android

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");

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionpanthroView Question on Stackoverflow
Solution 1 - AndroidKarthiView Answer on Stackoverflow
Solution 2 - AndroidMario VelascoView Answer on Stackoverflow
Solution 3 - AndroidM. Usman KhanView Answer on Stackoverflow
Solution 4 - AndroidLukapView Answer on Stackoverflow