效果图:

1、实体类Photo.ajva
public class Photo {
private String name;
private String date;
private long size;
private String path;
public Photo() {
}
public Photo(String name, String date, long size, String path) {
this.name = name;
this.date = date;
this.size = size;
this.path = path;
}
}
2、在AndroidManifest.xml里添加权限
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
3、Activity活动里读取手机中的图片
private void initData() {
Cursor cursor = getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, null, null, null, null);
List<Photo> mPhotoList= new ArrayList<Photo>();
while (cursor.moveToNext()) {
String path=cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media.DATA));
if(path!=null && path.length() >0) {
String name = cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media.DISPLAY_NAME));
File file = new File(path);
long modifieTime = file.lastModified();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
String date = sdf.format(new Date(modifieTime));
long size = cursor.getLong(cursor.getColumnIndex(MediaStore.Images.Media.SIZE));
Photo photo = new Photo(name, date, size, path);
mPhotoList.add(photo);
}
}
mPhotoList = sortList(mPhotoList);
}
private List<Photo> sortList(List<Photo> L){
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
Photo temp = new Photo();
for(int i=0; i<L.size()-1; i++){
for(int j=i+1; j<L.size();j++){
String date1=L.get(i).getDate();
String date2=L.get(j).getDate();
Date d1=sdf.parse(date1,new ParsePosition(0));
Date d2=sdf.parse(date2,new ParsePosition(0));
boolean flag = d1.before(d2);
if (flag){
temp = L.get(i);
L.set(i, L.get(j));
L.set(j, temp);
}
}
}
return L;
}