Android gets multiple recent photos from the album (get the photos stored by the camera)
When you are working on a company project, you need to customize the grid view of the displayed photos to display the first 20 photos that you have taken with a recent camera.
I checked the API provided by the system and did not find the path constant pointing directly to storing photos after taking photos with a camera. If anyone knows, please let me know. Thank you!
The following is an example of my stupid method. The main code snippet is as follows:
// Obtain the path of the SDcard 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); // sort the while (mCursor. moveToNext () {// print the 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. You can only retrieve the image String path = mCursor in the photo album that stores the photo after taking the photo. getString (mCursor. getColumnIndex (MediaStore. images. media. DATA); if (path. startsWith (sdcardPath +/DCIM/100 MEDIA) | path. startsWith (sdcardPath +/DCIM/Camera/) | path. startsWith (sdcardPath + DCIM/100 Andro) {Log. I (image path =, path); img_path.add (file: // + path) ;}} mCursor. close ();