I'm trying to package an image with my app, this image wont be used by any activity or layout, it's going to be used by an inner process which takes the File as parameter...
I didn't find any way to get the file or filepath from an asset or resource, all methods like:
context.getAssets().open();
context.getResources().openRawResource()
return an input stream to read the bytes from the file, but i need to File itself or the filepath (in order to make new File(filepath) and pass it as parameter to an third party API)
how can i do it?
Neither assets nor resources are files on the filesystem of the device. Your choices are:
Convince the developers of the third-party API to offer a better API, or
Use the methods in your question to get an InputStream
, and use that to copy the bytes to some file that you control (e.g., in getCacheDir()
), so you can use that file