Raw Folder Url Path?

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.

5

4 Answers

Uri video = Uri.parse("android.resource://");

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".

3

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

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

Now u can do this:

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Sarah Jenkins
Author

Sarah Jenkins

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.