Get image src from java file android
<p>I have an imageButton :</p>

<pre><code>img = (ImageButton)findViewById(R.id.image3);
</code></pre>

<p>I wanted to check if this img has a specific image , if yes then it changes to another image. </p>

<p>How can I  get and store the image resource and later can be used to compare with the current image source?</p>

<p>this is da code :</p>

<pre><code>ImageButton img = (ImageButton)findViewById(R.id.image3);
int resource = img.getResources().getInteger(android.R.drawable.btn_star_big_off);

if(resource==android.R.drawable.btn_star_big_off)
{
    img.setImageResource(android.R.drawable.btn_star_big_on);
}
</code></pre>

<p>Doesn't seem to be working
Any other way?</p>
