How To Make Sort Gallery Thumbnails Image By Date
I am developing an android applicaiton. This application get all thumbnail images from gallery. I want to sort these thumbnails by date, but I can't do it. Please help me. Get all
Solution 1:
Update columns
and orderBy
like this:
String[] columns = {MediaStore.Images.Media._ID, MediaStore.Images.ImageColumns.DATE_TAKEN};
String orderBy = MediaStore.Images.ImageColumns.DATE_TAKEN + " DESC";
and see if that helps.
You could also fetch real images instead of thumbnails and use image loading library that will take care of proper re-sizing. In this case replace your Thumbnails
references with ImageColumns
Solution 2:
this code will save the first 100 thumbs (SORTED by date)
Cursorcursor=this.getContentResolver().query( MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI,
projection, // Which columns to returnnull, // Return all rowsnull,
"image_id DESC");
// Get the column index of the Thumbnails Image IDintcolumnIndex= cursor.getColumnIndex(MediaStore.Images.Thumbnails.DATA);
for(inti=0;i<cursor.getCount();i++){
if (i==100) break;
cursor.moveToPosition(i);
mImagesFromGallery[i] = cursor.getString(columnIndex);
}
cursor.close();
Post a Comment for "How To Make Sort Gallery Thumbnails Image By Date"