I have some videos stored dynamically on R.res.raw.
For example, I can acces to the video called v.mp4 with this line of code:
String fileName = "android.resource://" + this.getPackageName() + "/" + R.raw.v;
OK, but I will describe the video that i must open with a string (“v”). Then, I tried to do this, but it didn’t works:
String fileName = "android.resource://" + this.getPackageName() + "/" + R.raw+".v";
I can’t do that, I get an error on R.raw
I also tried with this, but it doesn’t works:
String fileName = "android.resource://" + this.getPackageName() + "/res/raw/"+"v.mp4";
How can I solve this?
If you want to get any resource Path then there are two ways :
Using Resource Name
Syntax :
android.resource://[package]/[res type]/[res name]Example : If icon.png image file is available in res/drawable folder you can get path like :
String PATH="android.resource://com.my.package/drawable/icon";Using Resource Id
Syntax :
android.resource://[package]/[resource_id]Example : If icon.png image file is available in res/drawable folder you can get path:
String PATH="android.resource://com.my.package/" + R.drawable.icon;This were the examples to get the URI of any image file stored in drawable folder.
Similarly you can get URIs of res/raw folder also.