i have made a program in which i make a file in the data/data/mypackagename/ directory. From there i try and attach the file to an email and send it.
The problem that occurs is the file appears while sending the email as an attachment but the attachment is never received when the mail is received.
I believe that some problem is occuring when URI parse the file in the code:
emailintent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+outFileName));
My question is can i access data of the private folder in my phone, or should i always put it inside the sdcard.
If i put the file that i am making inside the sdcard, will the attachment problem dissappear?
Your application can access data in your application-local data store — the directory returned by
getFilesDir().However, you did not write the email program. The email program was written by somebody else, and you are starting an activity in that other application. The email program does not have rights to read files in your application’s data store.
You will either need to keep the file in question on external storage, as others have suggested, or use the version of
openFileOutput()that takesMODE_WORLD_READABLEas a parameter, so you have a file that other applications (such as the email program) can read.I certainly hope not. That should be
/data/data/com.company.NauticDates/files/attachment.ics. Please do not hardwire paths in your application. Please use the appropriate methods to get directories for you to use, such asgetFilesDir()oropenFileOutput()to put files in the application-local file store.