Reputation: 48
I'm searching a way to find and load images from Pictures folder depending on creation date. For example I want to load all pictures took in the last month, but I don't know their name.
I already read about Picasso library, but as written in the documentation, the url is required.
So instead of scan the entire folder and then check creation date, does it exist a quicker way to accomplish this task?
Thanks
Upvotes: 1
Views: 1941
Reputation: 4488
Maybe this could work for you. You may add selection clauses to query as well, to filter files by date for example.
Uri uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
Cursor cursor = getContentResolver().query(uri, new String[] {MediaStore.Images.Media.DATA}, null, null, MediaStore.Images.Media.DATE_ADDED + " ASC");
if (cursor != null) {
while (cursor.moveToNext()) {
Uri imageUri = Uri.parse(cursor.getString(0));
}
cursor.close();
}
Upvotes: 3
Reputation: 175
Use Timestamp while storing Images
String currentDateTimeString = DateFormat.getDateTimeInstance().format(new Date());
Give this as file name. This works only if you use separate activity for clicking images.
Upvotes: 1