Email from Internal Storage

Send email with attachment from internal storage

I'm assuming you are trying to send the file as an email attachment
using intents.

The reason why the file is empty is that the email app does not have
access to the file in /data/data/package_name/myfile_name, due to
Androids security model (the /data/data/package_name directory is
private to your app).

In order to add the file as an attachment, you need to write it to
public storage (such as the SD card) so the email app can access it.

Unable to add file from Internal storage as email attachment

I'm assuming you are trying to send the file as an email attachment using intents.

The reason why the file is empty is that the email app does not have access to the file in /data/data/package_name/myfile_name, due to Androids security model (the /data/data/package_name directory is private to your app).

In order to add the file as an attachment, you need to write it to public storage (such as the SD card) so the email app can access it.

Writing to a file (internal storage) and sharing it via mail/bluetooth.as a .txt file

 getFilesDir() 

Delivers path to private internal memory. Reachable for your app only. The mail app has no access.

Use getExternalFilesDir() instead. Also when you write the file using FileOutputStream.

On Android 7.0 this will not work either and you have to use a file content provider then.



Related Topics



Leave a reply



Submit