This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Android and the fly likes Strange in thumbnail image view from sdcard. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "Strange in thumbnail image view from sdcard." Watch "Strange in thumbnail image view from sdcard." New topic

Strange in thumbnail image view from sdcard.

allen android

Joined: Aug 16, 2009
Posts: 1
Hi, all

I got strange in thumbnail image display.
When i want to show image in gridview, it always display no images in sdcard. But if i entry android build-in ap "Gallery" first (Use it show image first), and then re-enter into my ap, it can show gridview image normally.(It is just like scan image first, and show image later)
I got no clue about this, who can help me.

The code below:
String[] imageAttribs = new String[] {

Cursor imageCursor;
imageCursor = this.managedQuery(

if ((imageCursor !=null)&&(imageCursor.moveToFirst())) {

String thumbsID;
String thumbsImageID;
String thumbsData;
String thumbsWidth;

Log.i(TAG, "[YES]imageCursor can move to first!");
Log.i(TAG, "[NO]imageCursor can not move to first!");

int thumbsIDCol = imageCursor.getColumnIndex(MediaStore.Images.Thumbnails._ID);
int thumbsDataCol = imageCursor.getColumnIndex(MediaStore.Images.Thumbnails.DATA);
int thumbsImageIDCol = imageCursor.getColumnIndex(MediaStore.Images.Thumbnails.IMAGE_ID);
int thumbsWidthCol = imageCursor.getColumnIndex(MediaStore.Images.Thumbnails.WIDTH);
int num=0;

String dbgmsg = "thumbsIDCol = "+Integer.toString(thumbsIDCol)+"; thumbsDataCol = "+Integer.toString(thumbsDataCol)+"; thumbsImageIDCol = "+Integer.toString(thumbsImageIDCol)+"; thumbsWidthCol = "+Integer.toString(thumbsWidthCol);
Log.i(TAG, dbgmsg);

do {
// Get the field values
thumbsID = imageCursor.getString(thumbsIDCol);
thumbsData = imageCursor.getString(thumbsDataCol);
thumbsImageID = imageCursor.getString(thumbsImageIDCol);
thumbsWidth = imageCursor.getString(thumbsWidthCol);
Log.i("BMP","size "+ thumbsWidth+" "+thumbsID+" "+thumbsData+" "+thumbsImageID);
if(thumbsImageID!= null) {
} while (imageCursor.moveToNext());
//Log.i(TAG, "******no image");
//showToast(this, "No Image In SDCard.");
//Toast.makeText(this, "No Image In SDCard.", 1000);
Toast.makeText(this, "No Image In SDCard.", Toast.LENGTH_SHORT).show();
setTitle("Picture Frame - [No Image In SDCard.]");
Button BTN = (Button)findViewById(;
Button SBTN = (Button)findViewById(;
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 9990

allen android wrote:

Please check your private messages for an important administrative matter.

[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
I agree. Here's the link:
subject: Strange in thumbnail image view from sdcard.
Similar Threads
How to play audio using this code in Grid View
How to add text to gridview
GestureListener on gridview
Get byte[] of image
Not Registering -4