title: Android EXIF data Image from Camera or Gallery lost
body: <p>I need to read some <code>Exif</code> properties of an <code>Image</code> (taken with the <code>Camera</code> or picked from the <code>Gallery</code>).</p>
  
  <p>Here is how I launch the <code>Camera</code>:</p>
  
  <pre><code>Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
      File file = new File(myObject.getLocalUrl());
      Uri fileURI = FileProvider.getUriForFile(context, context.getApplicationContext().getPackageName() + ".provider", file);
      intent.putExtra(MediaStore.EXTRA_OUTPUT, fileURI);
      startActivityForResult(intent, CAPTURE_IMAGE_REQUEST_CODE);
  </code></pre>
  
  <p>Here is how I launch the <code>Gallery</code> <code>Picker</code>:</p>
  
  <pre><code>Intent intent = new Intent();
  intent.setType("image/*");
  intent.setAction(Intent.ACTION_GET_CONTENT);
  intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
  startActivityForResult(Intent.createChooser(intent, getString(R.string.image_picker_select_image)), SELECT_IMAGE_FROM_GALLERY_REQUEST_CODE);
  </code></pre>
  
  <p>The problem is that for example, in the first case (<code>Camera</code>), after the <code>Image</code> is taken and saved in the <code>External</code> <code>Storage</code>, the <code>Exif</code> information get lost.</p>
  
  <p>The same for the <code>Images</code> picked from the <code>Gallery</code>. That's how I get the <code>Image</code> in the <code>onActivityResult</code> method:</p>
  
  <pre><code>Uri uri = data.getData();
  Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), uri);
  </code></pre>
  
  <p>And finally here is how I read the <code>Exif</code> data:</p>
  
  <pre><code>ExifInterface exifInterface = null;
      try {
          exifInterface = new ExifInterface(myObject.getLocalUrl());
      } catch (IOException e) {
          e.printStackTrace();
      }
      String exifOrientation = exifInterface.getAttribute(ExifInterface.TAG_ORIENTATION);
      String exifMake = exifInterface.getAttribute(ExifInterface.TAG_MAKE);
      String exifModel = exifInterface.getAttribute(ExifInterface.TAG_MODEL);
  </code></pre>
  
  <p>I've tried the next:</p>
  
  <ol>
  <li>Take a <code>picture</code> using my device <code>Camera</code> (without using my <code>App</code>).</li>
  <li>Read the <code>Exif</code> data using <code>ExifInterface</code>.</li>
  <li>It works like a charm.</li>
  </ol>
  
  <p>So I guess the problem is that when the <code>Image</code> is saved (after it's taken with the <code>Camera</code>) or the <code>Image</code> is picked from the <code>Gallery</code>, the <code>Exif</code> data gets lost.</p>
  
  <p>I've read at least 20-30 post here in <code>Stackoverflow</code> but basically the problem that everyone has is that the <code>orientation</code> <code>exif</code> information is lost, so the solution is writing the right <code>orientation</code> in the <code>Exif</code> data. </p>
  
  <p>That solution is not fine for me since I don't want to overwrite the <code>Exif</code> data, I just want to read the original one.</p>
  
  <p>Any ideas/hint?
  Thanks.</p>