1. Read the image information above the SD card
//the column where you want the return value to bestring[] Projection ={mediastore.images.thumbnails._id}; //picture information stored in the Android.provider.MediaStore.Images.Thumbnails database//quickly query the image in the database corresponding to store the road strengthcursor cursor =managedquery (MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, projection,
//List of columns to return: The column you want to return NULL,//Return All Rows NULL, NULL); intColumnIndex =Cursor.getcolumnindexorthrow (mediastore.images.thumbnails._id); Uriarray=NewUri[cursor.getcount ()];//Put the picture path in the array
2. Generate thumbnails of the pictures you read
while(Cursor.movetonext () &&i<Cursor.getcount ()) { //moves to the specified location, traversing the databasecursor.movetoposition (i); URI= Uri.withappendedpath (Mediastore.images.thumbnails.external_content_uri,cursor.getint (columnIndex) +""); Uriarray[i]=URI; Try{bitmap=Bitmapfactory.decodestream (Getcontentresolver (). Openinputstream (URI)); if(Bitmap! =NULL) { //Convert the original bitmap to a new bitmapNewbitmap = Bitmap.createscaledbitmap (Bitmap, the, the,true); Bitmap.recycle ();//Freeing Memory if(Newbitmap! =NULL) {publishprogress (Newloadedimage (Newbitmap)); } } } Catch(IOException e) {} I++; }
Android simple Picture Browser read SDcard picture + form thumbnail +gallery