Sort images in gridview using date

I use the following code, it selects an image from the gallery and displays the image in random order

String[] columns = { MediaStore.Images.Media.DATA, MediaStore.Images.Media._ID }; String orderBy = MediaStore.Images.Media._ID; imagecursor = managedQuery(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, columns, null,null, orderBy); int image_column_index = imagecursor.getColumnIndex(MediaStore.Images.Media._ID); 

I want the images to be sorted by the date in which they were taken (for example: Last first and oldest photos later) ...

and another problem: when I use the code above, it only uploads images to the DCIM folder, I want all the images from the phone to be ........

+4
source share
1 answer

Change orderBy to

 String orderBy = MediaStore.Images.Media.DATE_TAKEN + " DESC"; 
+8
source

Source: https://habr.com/ru/post/1501990/


All Articles