无法从内部存储作为电子邮件附件添加文件文件、邮件附件、电子

由网友(奈何桥上说永别)分享简介:我创建一个文件导入到内部存储(/数据/数据​​/程序包/ myfile_name),我想发送文件附件,但我越来越依恋一个空白文件(虽然我检查的文件管理器的文件时,文件是present,而不是空的同一个位置)。 I am creating a file into Internal storage (/data/data...

我创建一个文件导入到内部存储(/数据/数据​​/程序包/ myfile_name),我想发送文件附件,但我越来越依恋一个空白文件(虽然我检查的文件管理器的文件时,文件是present,而不是空的同一个位置)。

I am creating a file into Internal storage (/data/data/package_name/myfile_name), I want to send that file with attachment but I am getting a blank file in attachment(although I checked that file from file explorer, that file is present and not empty at same location).

和相同的code运行良好时,我用外部存储(我得到我的实际文件附件)。有,我们不能发送文件,该文件是present在内部存储任何限制?或者其他步骤我失踪?

And same code running well when I used external storage( I am getting my actual file in attachment). Is there any restrictions that we can not send file which are present in internal storage? Or other steps I am missing?

推荐答案

我假设你正试图发送文件的使用意图电子邮件附件。

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

之所以说该文件是空的是,电子邮件应用程序不能访问到文件 /数据/数据​​/程序包/ myfile_name ,由于机器人的安全模式(在 /数据/数据​​/程序包目录是私有的,你的应用程序)。

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).

为了将文件添加为附件,你需要将它写入公共存储(如SD卡),以便电子邮件应用程序可以访问它。

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.

阅读全文

相关推荐

最新文章