Android Media.insertImage and retrieve image from sd card

Go To StackoverFlow.com

0

I'm trying to save a bitmap to the sd card and by using the string returned in Media.insertImage, create an instance of the bitmap later on. But recreating it is not working. It is saving the bitmap correctly as i can see it in the gallery app but i just can't get the bitmap path correct or something. Any help i would really appreciate. Here is what I'm doing.

            Bitmap image = Bitmap.createBitmap(this.getWidth(), this.getHeight(), Bitmap.Config.RGB_565);
        this.draw(new Canvas(image));
        String s = Images.Media.insertImage(Mycontext.getContentResolver(), image, "mytitle", null);

and I'm trying to recreate it later on in the application where loc = s from above:

Bitmap bmp = BitmapFactory.decodeFile(loc);
2012-04-03 20:23
by devman
Have you tried Images.Media.getBitmap(Mycontext.getContentResolver(), Uri.parse(loc)) - onit 2012-04-03 20:47
that did the trick. I thought that it seemed so simple. Thanks for your help - devman 2012-04-03 20:57
No problem glad to help. I"m not sure why the path doesn't work in BitmapFactory, but I remember in some older code I wrote I had to retrieve images with that method instead as well - onit 2012-04-03 21:00


1

Use:

Images.Media.getBitmap(Mycontext.getContentResolver(), Uri.parse(loc))

2012-04-03 20:58
by onit
Ads