How to attach a text file stored locally in app directory

前端 未结 2 1540
南旧
南旧 2021-01-06 13:59

I have an Android app that saves a text file directly onto the phone, in the app\'s install directory. I need to allow the user to create a new email, attaching this saved t

相关标签:
2条回答
  • 2021-01-06 14:07

    I've just run into exactly the same issue (wanting to attach a text file to a Gmail message). If you look in the Android log, the reason for it is:

    02-28 21:01:28.434: E/Gmail(19673): file:// attachment paths must point to file:///mnt/sdcard. Ignoring attachment file:///data/data/com.stephendnicholas.gmailattach/cache/Test.txt
    

    As a workaround, you can use a ContentProvider to provide access to files in your application's internal cache so that Gmail can attach them. I've just written up a blog post on how to do it.

    Hopefully that's of some help :)

    0 讨论(0)
  • 2021-01-06 14:10

    I've seen this before and the only way I could solve it was by writing the file to the SD card.

    It's worth trying writing to the file to the SD card and attaching it if only to eliminate the files location as the cause of the problem.

    0 讨论(0)
提交回复
热议问题