App sending file by email
- By James_Watson
- Android Development
- 6 Replies
You should not pass that hard code path to the openFileOutput function. The legacy storage location will cause an unhandled exception, and thus your app will crash.
If you just need to share a file with email, I think app-specific storage is enough for you. You can use FileProvider component.
But if you insist on save your .txt file in a shared storage, your app will have to use the 'Storage Access Framework' or request 'All files access' from the user.
The former, the Storage Access Framework, requires user interactions to select directories using the system file picker.
The latter uses the ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION intent action to direct users to a system settings page where they can enable the following option for your app: Allow access to manage all files.
For more help, check the official Android developer website, please. Btw, it would be appreciated if you could leave a 5-star for my app available on Google Play.
If you just need to share a file with email, I think app-specific storage is enough for you. You can use FileProvider component.
But if you insist on save your .txt file in a shared storage, your app will have to use the 'Storage Access Framework' or request 'All files access' from the user.
The former, the Storage Access Framework, requires user interactions to select directories using the system file picker.
The latter uses the ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION intent action to direct users to a system settings page where they can enable the following option for your app: Allow access to manage all files.
For more help, check the official Android developer website, please. Btw, it would be appreciated if you could leave a 5-star for my app available on Google Play.

