I have set an image in an image view. Now I want to save this state and need to know the image path of that image. Is there a way to do that?
UPDATE:
// Decode, scale and set the image.
Bitmap myBitmap = BitmapFactory.decodeFile(selectedImagePath);
Bitmap scaledBitmap = Bitmap.createScaledBitmap(myBitmap, NEW_WIDTH, NEW_HEIGHT, true);
myBitmap.recycle();
myBitmap = null;
mImageView.setImageBitmap(scaledBitmap);
Not directly, once an image is set on an
ImageViewit is turned into aDrawableand all else is forgotten. However, you could use tags for this purpose. Any view can have a tag associated with it that represents some metadata about that view. You could do something like:You might also consider creating a subclass of
ImageViewto encapsulate this extra function to help make your code a little easier to read and maintain.HTH