Search code examples
androidgmailandroid-intentattachment

Attaching a file from secure storage in Gmail from my app


My app has an option to send out the log, which is store in the app's secure storage. The path to the file is "/data/data/com.mycompany.myapp/files/log.zip". The file's permissions have been chnged to MODE_WORLD_READABLE, and the intent to launch email is:

Intent i = new Intent(Intent.ACTION_SEND);
i.setType("application/zip");
i.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///data/data/com.mycompany.myapp/files/log.zip));
startActivity(Intent.createChooser(i, "Send Error Log"));

If the file is located on the SD card, there is no problem. But when it's secure storage, there is no attachment. I'm pretty sure that it's not a premissions issue because it works perfectly with the stock email client and with the TouchDown Exchange app. It's only Gmail that has this problem. Is this a glitch in Gmail, or am I missing something?

Thanks.


Solution

  • Nevermind, I found the answer -- Gmail does not allow any attachments unless they come from the SD card. I ended up having to copy the file to external storage cachce, and then everything worked. It sucks that Gmail arbitrarily decides that it won't use files on insternal storage, even if permissions are correct!