Sending a file as an email attachment & SD directories


Man. I spent hours creating a custom dialog that would ask the user if they want to export an XML file to the SD card or send it in an email. Then I decided it’s time to see how you would build such an implicit intent. The only answers I found so far are on Stack Overflow, and they say that you can only do such a thing for a file that is on the SD card. You can’t do it for files in an apps private storage area. Is this still true? You can’t email a file unless you put it on the SD card first?

I put the default xml files in the assets directory, so no one can mess with them, but I want them to be able to export them, make changes, and then import their changed versions. Imported files would be placed in the apps private data area. Now I am thinking to just let them export them to the SD card, and they can figure out how to send it as an attachment from their email client.

But that brings up another question. The directories on the SD card are very limited. Environment.DIRECTORY_DOWNLOADS is the only one that I can see using for xml files. Is it even possible to create your own directory on the SD card that is not a subdirectory of one of the existing ones? How do other apps manage the export/import of their own files?



I’ve been trying to figure out how to attach the picture I took onto an text msg or email. Any suggestions?

Thanks for your help,


Re: the SD card… well.

1- The file you send doesn’t have to be on the SD card. It does have to be public, though. Files created on the SD card are public by default, but files created in private storage are private by default.

2- Your plan for shipping defaults in the assets folder and then exporting to another area sounds great to me.

3- You have your own folder on the external SD card that you can do whatever you want with (getExternalFilesDir()). Just create folders within that storage area as suits your need and you should be good.

Bobr - I try not to provide too much explicit guidance for challenges. If you have something specific that is stumping you let us know.



Thanks for the update. I appreciate giving me information on this subject.