Android : Store an image from camera to database and the show it
<p>Here I write camera snapshot on the db.</p>

<pre><code> `private SQLiteDatabase db;
// SOME CODE HERE ///
InputStream is =new ByteArrayInputStream(data);
BufferedInputStream bis = new BufferedInputStream(is,128);
ByteArrayBuffer baf = new ByteArrayBuffer(128);
int current = 0;
while ((current = bis.read()) != -1) {
     baf.append((byte) current);
}
baf.toByteArray();
ContentValues initialValues = new ContentValues();
initialValues.put("mapimg", baf.toByteArray();
db.insert(DATABASE_TABLE, null, initialValues);
</code></pre>

<p>`
This writes correctly in the db a new row.</p>

<p>When I try to show the image :</p>

<pre><code>DbUtil db = new DbUtil(this);
List&lt;Row&gt; rows = db.fetchAllRows();
db.close();
byte[] imageByteArray= rows.get(10).getMapimg();
ByteArrayInputStream imageStream = new ByteArrayInputStream(imageByteArray);
Bitmap theImage = BitmapFactory.decodeStream(imageStream);
ImageView imageView ;
imageView = (ImageView)findViewById(R.id.ImageView01);
imageView.setImageBitmap(theImage);
</code></pre>

<p>In the xml :</p>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"

    &gt;


   &lt;ImageView
         android:id="@+id/ImageView01"
        android:layout_width="300px"
        android:layout_height="300px"
        android:scaleType="center"
         /&gt;



&lt;/LinearLayout&gt;
</code></pre>

<p>But no image appears on screen.
Where is the problem  ? </p>
