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
How to Simulate Low Memory in the Android Emulator
How to Draw an Arrowhead (In Android)
Android Color Between Two Colors, Based on Percentage
Android Getintent().Getextras() Returns Null
How to Declare on UI Component in Android with Kotlin
Calling a Java Servlet from JavaScript
How to Find Gcd, Lcm on a Set of Numbers
Reading in from System.In - Java
Is Dalvik's Memory Model the Same as Java'S
Eclipse: Jvm Terminated. Exit Code=2
Rotate Marker and Move Animation on Map Like Uber Android
Android: Why Setvisibility(View.Gone); or Setvisibility(View.Invisible); Do Not Work
Android - Imageloader Must Be Init with Configuration Before Using in Uil
Read Data from SQLite Where Column Name Contains Spaces