Java – How to convert byte[] or bitmaps to integers (R.drawable.picture) Android Java

How to convert byte[] or bitmaps to integers (R.drawable.picture) Android Java… here is a solution to the problem.

How to convert byte[] or bitmaps to integers (R.drawable.picture) Android Java

I want to convert

byte[] image = cursor.getBlob(5);

Bitmap bit_image = getImage(image);

Convert byte[] or Bitmap to R.drawable.picture.

I need it to be an integer (int instead of int[]) because my custom ListView only accepts ampersands.

list_view_class.add(new List_view_class(R.drawable.picture,text);

Solution

You can’t do what you want.
R.drawable or R.string and so on are not the resources themselves, but strong references to resources in your app >. So you can’t convert any type of object to R or something else. What you can do is use Bitmap and display it directly.

Related Problems and Solutions