Question

I am working on a project where I need to take multiple images from camera. I am looking for a way where I can delete images from gallery which are taken after particular date/time.

Please advice

Was it helpful?

Solution

Have you tried to query the MediaStore.Images...something like this:

String[] projection = { MediaStore.Images.Media.DATA };
String selection = MediaStore.Images.Media.DATE_TAKEN + " < ?";
String[] selectionArgs = { String.valueOf(YOUR_DATE_MILLIS) };
Cursor cursor = context.getContentResolver()
    .query(Images.Media.EXTERNAL_CONTENT_URI, 
        projection, 
        selection, 
        selectionArgs, 
        null);

if (cursor != null && cursor.getCount() > 0) {
    while (cursor.moveToNext() {
        String imagePath = cursor.getString(0);
    }
}

cursor.close();

OTHER TIPS

Create a procedure which will be launched with your application, checking all the files of a particular folder, and deleting the images from a certain period.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top