Android get thumbnail images and videos on SD card

Source: Internet
Author: User

Need to quickly extract pictures and video thumbnails to directly access Android.provider.MediaStore.Images.Thumbnails And android.provider.MediaStore.Video.Thumbnails These two databases, you can query the thumbnail.

How do you judge a document? You can traverse the database by cursor, comparing the value of the Internal_content_uri field, which is a URI that holds the full path to the multimedia file on the Android phone's SD card.

Uri Originaluri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;

If the video is MediaStore.Video.Media.EXTERNAL_CONTENT_URI;

Contentresolver CR = This.getcontentresolver ();

Cursor Cursor = cr.query (Originaluri, NULL, NULL, NULL, NULL);

if (cursor = = NULL) {

Return

}

For (Cursor.movetofirst ();! Cursor.isafterlast (); Cursor.movetonext ()) {

Long Thumbnailsid = Cursor.getlong (cursor. Getcolumnindex ("_id"));

Bitmap Bitmap = MediaStore.Images.Thumbnails.getThumbnail (CR,

Thumbnailsid, Video.Thumbnails.MICRO_KIND, NULL);

If the video is

Bitmap Bitmap = MediaStore.Video.Thumbnails.getThumbnail (CR,

Thumbnailsid, Video.Thumbnails.MICRO_KIND, NULL);

return bitmap;

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.