Tuesday, August 23, 2011

[android-developers] Re: how to retrieve images from a sql database?

I'm not sure why you wouldn't have access to the MediaStore, it's been
available since API level 1.

If you really want to try putting the images directly in the database,
just Google something like "Android SQLite Blob" because that's what
you'll need to use. I'm sure there are examples out there. Make sure
to use BitmapFactory Options when recreating your Bitmaps, otherwise
you're probably going to crash the app after creating a few Bitmaps
because you've completely run out of memory on the device.

Good luck.

On Aug 23, 8:59 am, Abhi <abhishek.r.sha...@gmail.com> wrote:
> @Ibendlin - Yes, SQLite on device is what I meant. Sorry about the
> confusion
> @Drezden - I somehow don't have that option to add images to
> MediaStore, keeping the file path in the SQLite database. I would like
> to still try retrieving those images stored in the database before
> deciding which way to really go. Anything you could tell me about
> doing that?
>
> Thanks,
>
> AB
>
> On Aug 22, 5:45 pm, Drezden <mmjohns...@gmail.com> wrote:
>
>
>
>
>
>
>
> > What you're looking for in SQLite is called a BLOB (Binary Large
> > Object) but this is usually NOT recommended, the better approach would
> > be to add the images to your MediaStore and then store the file path
> > in your SQLite database.  Then you can retrieve the images as needed
> > from the resource path like this:
>
> > BitmapFactory.Options options = new BitmapFactory.Options();
> > options.inSampleSize = 2;
> > options.inTempStorage = new byte[16*1024];
> > options.inJustDecodeBounds = false;
>
> > Bitmap preview =
> > BitmapFactory.decodeStream(getContentResolver().openInputStream(imagePath), null,options);
>
> > Hope this helps.
>
> > On Aug 22, 3:04 pm, Abhi <abhishek.r.sha...@gmail.com> wrote:
>
> > > Hi
>
> > > I have a database of low res images that I am trying to use for one of
> > > my applications. What I would like to do is to retrieve the images one
> > > by one and display them in a slideshow. I was told that images are
> > > stored as byte arrays in sql database. I am new to sql and looking for
> > > some direction on how to do this, what query to put and how to extract
> > > the byte array from the database for further use.
>
> > > Any help appreciated.
>
> > > Thanks,
> > > AB

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment