In case I have to set an image on a button, programmatically, then I use the following code:

```
        Drawable img;
        ToggleButton tb_button = (ToggleButton) findViewById(R.id.tglButton);
        img = ResourcesCompat.getDrawable(getResources(), R.drawable.p189, null );
        tb_button.setCompoundDrawables(img,null,null,null);

```

Now the situation is that I have read the name of the image from a database into a variable. Thus lets assume that my variable has the following value:

```
String img_str= "p189";

```

Now how do I set the same image on the button when the image name is stored inside a variable.