My application stores data locally in the native SQLite db, and I want to allow users to export this data by emailing themself a .csv file. In order to do this I'm generating the .csv from the database and writing it to the SD card, then attaching it to an email:
StringBuilder csv = generateFile();
writeFile(csv.toString(),"file.csv");
Intent email = new Intent(android.content.Intent.ACTION_SEND);
email.setType("application/octet-stream");
email.putExtra(android.content.Intent.EXTRA_STREAM, Uri.parse("file://sdcard/file.csv"));
Which all works great. What I'm wondering, though, is if it is possible to skip the step of writing to SD first, and directly attach the data.