How to attach a text file stored locally in app directory

前端 未结 2 1539
南旧
南旧 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 :)

提交回复
热议问题