I have native JNI implementation and for now I have my media files under the app dir /storage/emulated/0/Android/data/com.my_app.debug/files/Models/my_media_file.mp4
in order to start read one of the files I need to pass a path to JNI
where inside I use such method that expect to get path_to_mp4_file
bool Decoder::InitFromFile(std::string const &filename)
{
m_file.open(filename, std::ios::binary);
if (!m_file.is_open())
{
return false;
}
...
}
And all works, but now I need to read from build-in
raw
folder, so now in order to get path to my file I am using this way
fun foo()
{
...
val path = "android.resource://" + activity!!.packageName + "/" + R.raw.my_media_file
val uri = Uri.parse(path)
JNIImplementation.InitFromFile(uri.path)
...
}
But now uri = android.resource://com.my_app.debug/2131492865
if I get uri.path = /2131492865
.
Issue is that if I pass this uri.path
as a path to InitFromFile
method I get an error, because I can't open file by path /2131492865
.
So, as far as I understand there is should be a way to read from raw or assert
folder native way or something like this
How to do it?
Or maybe there is a way how to put this media file in app (build-in
) and have access to get path as to regular file? I mean somehow look at this file not as a resource, but as a simple file?