简体   繁体   中英

Get the file path from attachment on Gmail

I´m trying to get a csv file from an email attachment , the idea is that when user selects the attachment an option to open with my app will appear . I need to know the best way to get the file path from the attachment .

Thanks in advance.

There is not necessarily a "file path" for the attachment.

If you have an activity set up to view files of the proper MIME type, and the user chooses to use your activity to view the email attachment, you will get a Uri to that attachment in getIntent().getData() . That Uri may be a file:/// Uri . It may be something else. In particular, for Gmail, it will be a content:// Uri . Use a ContentResolver and openInputStream() to read in the contents pointed to by that content:// Uri .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM