Android Gallery view with images saved in sqlite as blob
<p>i need to show images from sqlite database into gridview or gallery view.<br>
this is the code for displaying on a single view:
</p>

<pre><code>mMain = (ImageView) findViewById(R.id.ivMain);
byte[] blob = imgs.getBytes(); //there is a method that will return the bytes from the database
ByteArrayInputStream inputStream = new ByteArrayInputStream(blob);
Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
mMain.setImageBitmap(bitmap);
</code></pre>

<p>i have the android tutorial for grid view but it gets the image from file
</p>

<pre><code>// references to our images
private Integer[] mThumbIds = {
R.drawable.sample_2, R.drawable.sample_3
... }
</code></pre>

<p>is there a way to populate the gridview from the sqlite database?</p>

<p><strong>UPDATE:</strong><br>
Im using the ImageAdapter provide in android tutorial:<br>
<a href="http://developer.android.com/resources/tutorials/views/hello-gridview.html" rel="nofollow">http://developer.android.com/resources/tutorials/views/hello-gridview.html</a><br>
my code becomes this:</p>

<pre><code>ArrayList&lt;byte[]&gt; image_arr = new ArrayList&lt;byte[]&gt;();
//loop through all images on sqlite
for(int l = 0 ;l&lt; db.getAllImages().size(); l++){
    Image imgs = db.getAllImages().get(l); 
    byte[] blob = imgs.getBytes();  
    image_arr.add(blob);

    ByteArrayInputStream inputStream = new ByteArrayInputStream(blob);
    Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
   // mMain.setImageBitmap(bitmap);
}
//TODO; find way to make the bitmap get to the ImageView

Gallery gallery = (Gallery) findViewById(R.id.gallery);
gallery.setAdapter(new ImageAdapter(this));
</code></pre>

<p>This code is on main activity so i need to find way to pass the resources in ImageView which is in other file.</p>
