[英]ContentResolver — how to get file path of attachment
I need help in accessing the attachment received in an email. 在访问电子邮件中收到的附件时,我需要帮助。
I have setup intent filter for my activity and on clicking the attachment in the gmail app, my activity is launched with intent containing following Uri. 我为自己的活动设置了意图过滤器,并在gmail应用中单击附件后,我的活动即启动,意图包含以下Uri。
content://gmail-ls/xxxx@gmail.com/messages/2407/attachments/0.1/BEST/false
I have tried following query and filename returned is null. 我尝试了以下查询,并且返回的文件名为null。
String[] projection = {MediaStore.MediaColumns.DATA};
Cursor c = context.getContentResolver().query(uri, projection, null, null, null);
if (c.moveToFirst()) {
fileName = c.getString(0);
}
Anyone, please let me know how can I access the file received in the attachment ? 有人,请让我知道如何访问附件中收到的文件?
Thanks. 谢谢。
Anyone, please let me know how can I access the file received in the attachment ?
有人,请让我知道如何访问附件中收到的文件?
There isn't necessarily a file at all, let alone one that you have direct access to. 根本没有文件,更不用说直接访问的文件了。 Gmail, in particular, had better be storing its attachments in a place where other apps cannot access them directly.
特别是Gmail,最好将其附件存储在其他应用无法直接访问它们的地方。
To use the attachment, use the Uri
with a ContentResolver
to get an InputStream
on it. 要使用附件,请将
Uri
与ContentResolver
一起使用以在其上获取InputStream
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.