Android - How to get Uri from raw file?
Try this:
uri = Uri.parse(
ContentResolver.SCHEME_ANDROID_RESOURCE
+ File.pathSeparator + File.separator + File.separator
+ context.getPackageName()
+ File.separator
+ R.raw.myrawname
);
Try this approach, use getResources().openRawResource(ResourceID)
as your inputStream.
Somewhere along this :
//FileInputStream fileInputStream = new FileInputStream(file);
InputStream inputStream = getResources().openRawResource(R.raw.usa_for_africa_we_are_the_world);
DataInputStream dataInputStream = new DataInputStream(inputStream);
audioTrack.play();
getResources().openRawResource(ResourceID)
returns an InputStream
EDIT : Remove these code if you use the above approach
Uri url = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.usa_for_africa_we_are_the_world);
File file = new File(url.toString());
Hope this helps, Good Luck! ^^