i am using camera to take photos and want to store in database(SQLite). Stored photos have to be displayed in the another activity with list view like this list view images
Create DataBase helper class like this..
On Capturing the image insert the image by converting into bytes:
Imagehelper help=new Imagehelper(this);
if (requestCode == CAMERA_REQUEST) {
Bitmap photo = (Bitmap) data.getExtras().get("data");
imageView.setImageBitmap(photo);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
photo.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
help.insert(byteArray);
}
To retrieve Form the Database:
Imagehelper help=new Imagehelper(this);
Cursor c= help.getAll();
int i=0;
if(c.getCount()>0)
{
Bitmap[] array=new Bitmap[c.getCount()];
c.moveToFirst();
while(c.isAfterLast()==false)
{
byte[] bytes=c.getBlob(c.getColumnIndex("imageblob"));
array[i]=BitmapFactory.decodeByteArray(bytes, 0, 0);
c.moveToNext();
i++;
}
Log.e("Bitmap length",""+array.length);
}
Pass this Bitmap array to ListView