I wanna read in a bitmap that I have in my drawable folder and store it as a Bitmap variable so that I can set it as a background. Would the best way to do this be using a “file reader”? like
Bitmap decodeFile (String pathName) method
Or is there a way to just set it like this:
Bitmap bmp = R.drawable."bitmapFileName";
(I have tried this but returns an int, just wondering if I was on the right track)
Any help would be great 🙂
The
R.drawable."bitmapFileName"is, indeed, just an integer, for it is an index (static integer) at your project’s R class (see more here). You can load your bitmap from the resources’s folder like this:I found this code at the Android Development Community.