Search code examples
androidandroid-image

Load images depending on creation date


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


Solution

  • 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();
    }