title: Android: share CSV file
body: <p>My aplication can generate CSV files that I want to share. I'm using MIME type <code>text/comma_separated_values/csv</code>, but when I send the <code>Intent</code> the chooser isn't shown, I guess my device doesn't know how to handle the file. Which type should I use?</p>
  
  <p>This is my code:</p>
  
  <pre><code>    Uri csv = lh.createDailyCSV();
  
      if(csv == null){
           Toast.makeText(this, getString(R.string.error_creating_csv), Toast.LENGTH_LONG).show();
      }
      else{
          Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
          sharingIntent.setType("text/comma_separated_values/csv");
          sharingIntent.setData(csv); 
          startActivity(Intent.createChooser(sharingIntent, getResources().getText(R.string.send_to)));
      }   
  </code></pre>
  
  <p>I declared in my manifest:</p>
  
  <pre><code>    &lt;intent-filter&gt;
          &lt;action android:name="android.intent.action.SEND" /&gt;
  
          &lt;category android:name="android.intent.category.DEFAULT" /&gt;
  
          &lt;data android:mimeType="text/comma_separated_values/csv" /&gt;
      &lt;/intent-filter&gt;
  </code></pre>
  
  <p>And I get the exception</p>
  
  <pre><code>03-12 12:19:23.430: E/ActivityThread(24011): Activity com.android.internal.app.ChooserActivity has leaked IntentReceiver com.android.internal.app.ResolverActivity$1@412fc920 that was originally registered here. Are you missing a call to unregisterReceiver()?
  </code></pre>
  
  <p>I've read this Exception occurs when there is none or just 1 option in the chooser.</p>
  
  <p>[EDIT]</p>
  
  <p>I changed how I attach the data to the Intent. Instead of sharingIntent.setData(csv) I used:</p>
  
  <pre><code>sharingIntent.putExtra(Intent.EXTRA_STREAM, csv);
  </code></pre>
  
  <p>And now the chooser works fine, but if I try to send the file via e-mail I get an error: File couldn't be shown.</p>
  
  <p>[/EDIT]             </p>