title: Is it possible to retrieve images from gallery that is captured by camera in a certain time span
body: <p>I'm working on a project on which I need to retrieve images from gallery that is captured by camera in a certain time span. Please advice a way to do this.</p>
  
  <p>Thanks.</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>Here is what I found,</p>
  
  <p>You can make use of ExifInterface. <a href="http://developer.android.com/reference/android/media/ExifInterface.html" rel="nofollow noreferrer">Here is the doc</a>. </p>
  
  <p>First, retrieve images taken by camera by using <a href="https://stackoverflow.com/questions/4484158/list-all-camera-images-in-android/4495753#4495753">this</a></p>
  
  <p>Then get the real path of images by using this</p>
  
  <pre><code>private String getRealPathFromURI(Uri contentURI, Activity activity) {
      Cursor cursor = activity.getContentResolver()
                      .query(contentURI, null, null, null, null);
      if (cursor == null) { // Source is Dropbox or other similar local file
          // path
          return contentURI.getPath();
      } else {
          cursor.moveToFirst();
          int idx = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA);
          return cursor.getString(idx);
      }
  }
  </code></pre>
  
  <p>Now use this to get the time the image captures using the following code</p>
  
  <pre><code>String currentImageFile = Utility.getRealPathFromURI(flyerUri, getActivity());
  
              ExifInterface ei = null;
              try {
                  ei = new ExifInterface(currentImageFile);
                  if(ei != null)
                  {
                      Log.e("","---&gt; date and time "+ei.getAttribute(ExifInterface.TAG_DATETIME));
                  }
              } catch (IOException e) {
                  e.printStackTrace();
              }
  </code></pre>
  
  <p>Now you have the images captured by camera and time the picture was taken. Use it according to your requirement. :)</p>