title: How to send a photo to Instagram using my Android app?
body: <p>My app takes photos and I want to share it on Instagram.</p>
  
  <p>My app save the image in this directory</p>
  
  <pre><code>File storagePath = new File(Environment.getExternalStorageDirectory() + "/DCIM/Camera/tubagram");
  </code></pre>
  
  <p>Now I'm trying to get the last picture I took to share in Instagram using this code</p>
  
  <pre><code>Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
  shareIntent.setType("image/*");
  
  final ContentResolver cr = getContentResolver();
  final String[] p1 = new String[] {MediaStore.Images.ImageColumns._ID, MediaStore.Images.ImageColumns.DATE_TAKEN};
  Cursor c1 = cr.query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, p1, null, null, p1[1] + " DESC");
  
  if (c1.moveToFirst() ) {
  
      Log.i("Test", "last picture (" + c1.getString(0) + ") taken on: " + new Date(c1.getLong(1)));
  }
  
  shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+Environment.getExternalStorageDirectory() + "/DCIM/Camera/tubagram/" + c1.getString(0)));
  shareIntent.setPackage("com.instagram.android");
  
  c1.close();
  
  startActivity(shareIntent);
  </code></pre>
  
  <p>I receive a Toast with this error message "Unable to download file".
  This Toast is sent by Instagram.</p>
  
  <p>I tried to use this link example - <a href="https://stackoverflow.com/questions/13497543/share-a-photo-in-instagram">share a photo in instagram</a> - but didn't work.</p>