无法从内部存储作为电子邮件附件添加文件 [英] Unable to add file from Internal storage as email attachment

查看:318
本文介绍了无法从内部存储作为电子邮件附件添加文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建一个文件导入到内部存储(/数据/数据​​/程序包/ 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.

这篇关于无法从内部存储作为电子邮件附件添加文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆