Raw Folder Url Path

Raw folder url path?

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

How can I get file path on raw resources in Android Studio?

how can i get file path on raw resources?

You can't. There is no path. It is a file on your development machine. It is not a file on the device. Instead, it is an entry in the APK file that is your app on the device.

If your library supports an InputStream instead of a filesystem path, getResources().openRawResource() on a Context to get an InputStream on your raw resource.

android - how to get path of mp3 stored in raw folder

Is it possible to get file path by using R.raw.mp3file

No, because it is not a file on the device. It is a file on the hard drive of your development machine. On the device, it is merely an entry in an APK file.

Either:

  • Do whatever you are trying to do some other way that does not involve a file path, or

  • Use openInputStream() on a Resources object (you can get one from any Context via getResources()), and use Java I/O to copy the contents of that resource to a local file, such as on internal storage

Android how to get file path from /res/raw/

You can execute your bash like this:

BufferedReader r = new BufferedReader(new InputStreamReader(scriptFile));
String command = "";
List<String> commands = new ArrayList<>();
try {
command = r.readLine();
commands.add(command);
while(command != null){
command = r.readLine();
commands.add(command);
}

Process p = new ProcessBuilder().command(commands).start();
} catch (IOException e) {
e.printStackTrace();
}

And you can get the Uri of the raw resource in order to create a new File object:

Uri uri = Uri.parse("android.resource://com.your.package/raw/filename");


Related Topics



Leave a reply



Submit