Reprint please indicate source: http://blog.csdn.net/android_ls/article/details/39928519
When you are working on a company project, you encounter the need to customize the grid view that displays your photos, showing the top 20 photos taken by the user recently with the camera.
I looked at the system provides the API, did not find a direct point to take pictures after the camera to store the path constant, if you know, please tell me, thank you!
Here is the stupid way I used, the main code snippet is as follows:
Get SDcard Card path string sdcardpath = environment.getexternalstoragedirectory (). ToString (); contentresolver mcontentresolver = mainactivity.this.getcontentresolver ( ); cursor mcursor = mcontentresolver.query (MediaStore.Images.Media.EXTERNAL_CONTENT_ uri, new string[]{mediastore.images.media._id, mediastore.images.media.data}, mediastore.images.media.mime_type + "=? OR " + MediaStore.Images.Media.MIME_TYPE + " = ", new string[] { "Image/jpeg", "Image/png" }, mediastore.images.media._id + " desc"); // sorted by Image ID in descending order while (Mcursor.movetonext ()) { // Print Log to view the value of the photo ID long id = Mcursor.getlong (Mcursor.getcolumnindex (mediastOre. images.media._id));       LOG.I ("mediastore.images.media_id=", id + ""); // filter out unwanted images, Only get pictures in albums that store photos after taking pictures string path = mcursor.getstring ( Mcursor.getcolumnindex (MediaStore.Images.Media.DATA)); if ( Path.startswith (sdcardpath + "/dcim/100media") | | path.startswith (sdcardpath + "/dcim/camera/") | | path.startswith (sdcardpath + "Dcim/100andro")) { log.i ("image path= ", path); img_path.add (" file://" + path); } } mcursor.close ();
Android gets multiple recently taken photos from albums (Get photos stored by camera photo)