Reputation: 33956
I'm trying to build a simple image gallery with a viewpager, the app is intended for people with bad eyesight so instead of showing an image grid first it should jump right in to the last image and let users swipe left to see the next one, however I don't know how to retrieve images from the phone memory.
Answering any of this questions would help me out:
How can I get all images that appear on the gallery (no matter their location)? or provided images are ordered from newest to oldest, how can I get image 0 and add it to an imageview?
Upvotes: 1
Views: 557
Reputation: 2898
To sort the images by date,
MediaStore.Images.Media.DATE_ADDED + " DESC""
To retrieve images from the internal memory only, use Images.Media.INTERNAL_CONTENT_URI
,
Below code will return all the images from the Internal phone memory, sorted by the added date.
Cursor cursor = context.getContentResolver().query(Images.Media.INTERNAL_CONTENT_URI,
MediaStore.Images.Media.DATA,
null,
null,
MediaStore.Images.Media.DATE_ADDED + " DESC");
Hope this will give you some hint, change the cursor as per the desired functionality.
Upvotes: 3