As discussed in another thread (http://groups.google.com/group/android- developers/browse_thread/thread/d79bfa05528cbbee/2b08822eeb767b7b), my program allows users to export data by email. I do this by writing the data to a temporary file, then attaching it to an Intent:
startActivity(new Intent(Intent.ACTION_SEND).setType("application/ vnd.mytype").putExtra(Intent.EXTRA_STREAM, android.net.Uri.fromFile(tempFile))); I've run into a difficulty with this approach, though: making sure the temporary file gets deleted when it isn't needed anymore. On most platforms, File.createTempFile() creates the file in a special location such as /tmp which ensures it will get deleted the next time the computer boots. Not so on Android: it just creates the file at the root level of the SD card, causing "temp" files to just build up and never get deleted. I tried to force it to get deleted by calling deleteOnExit(). No good: it still doesn't get deleted, presumably because Android apps never really "exit", they just get suspended and then killed. So it looks like I need to manually delete the file when it's no longer needed. The question is, how can I tell when it's no longer needed? In this case, it's not a matter of when *my* program is done with it, but rather when the email client is done with it. Does anyone have suggestions for how to deal with this? Peter -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en