Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7552421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:45:26+00:00 2026-05-30T10:45:26+00:00

i need to show images from sqlite database into gridview or gallery view. this

  • 0

i need to show images from sqlite database into gridview or gallery view.
this is the code for displaying on a single view:

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);

i have the android tutorial for grid view but it gets the image from file

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

is there a way to populate the gridview from the sqlite database?

UPDATE:
Im using the ImageAdapter provide in android tutorial:
http://developer.android.com/resources/tutorials/views/hello-gridview.html
my code becomes this:

ArrayList<byte[]> image_arr = new ArrayList<byte[]>();
//loop through all images on sqlite
for(int l = 0 ;l< 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));

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T10:45:27+00:00Added an answer on May 30, 2026 at 10:45 am
    private void getDataAndPopulate() {
    
        image = new ArrayList<byte[]>();
        caption = new ArrayList<String>();
    
        cursor=db.rawQuery("select * from NAME",null);
    
    
        while (cursor.moveToNext()) {
    
            byte[] temp_image = cursor.getBlob(2);
            String temp_caption = cursor.getString(1);
            String temp_id= cursor.getString(0);
            image.add(temp_image);
            caption.add(temp_caption);
            id.add(temp_id);
        }
        String[] captionArray = (String[]) caption.toArray(
                new String[caption.size()]);
    
        ItemsAdapter itemsAdapter = new ItemsAdapter(Item_show_grid.this, R.layout.item_grid,captionArray);
        gv.setAdapter(itemsAdapter);
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to display 3 random images from SQLite database horizontally. Since it's impossible
In my app I need to show various images(from server). The images retrieved from
I display set of images(small). I need to show the larger image(300*300) at some
I need to create a slide show of some images that can go full
So i have this EasySlider 1.7 and loads of images i want to show
Why this code show me a window without image? I try to use QByteArray
i want to show images from external url listed in external xml (similar to
I am in need to use This Class to server multiple files (img/video/mp3) from
I have a gridview which contains a textbox control. I need to show the
So basically everyone at one point needs to do this,load some images from web

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.