Search code examples
androidandroid-drawableandroid-resourcesandroid-file

Convert local image file to resource ID


I have an image file locally stored in my phone memory(or, SD card). From my code, I am totally able to open the file an convert it to Bitmap and do stuff. But I need a resource id instead. I am not sure how to get the resource id (i.e. int) from a Bitmap or file path. Can anybody help?


Solution

  • There is no way to get a resource ID for a file on the filesystem of the device. Resources are files compiled into your APK; they are not files on the filesystem of a device.