Android local file share doesn't share contents of file
See original GitHub issueSteps to reproduce
- Attempt to share a local text file via
Share.open
using the local path as described in the docs, e.g.url: "file:///storage/emulated/0/test.txt"
Expected behaviour
The contents of the file should be shared to the selected app
Actual behaviour
Instead of the file contents the file url is shared to the app, e.g. if I share to Gmail the string “file:///storage/emulated/0/test.txt” is copied into the email.
Environment
- React Native version: .55.3
- React Native platform + platform version: Android 8.1.0
react-native-share
Version: 1.1.2
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Android local file share doesn't share contents of file #385
if I share to Gmail the string "file:///storage/emulated/0/test.txt" is copied into the email.
Read more >Sharing a file - Android Developers
Once you have set up your app to share files using content URIs, you can respond to other apps' requests for those files....
Read more >Share files or apps with Nearby Share - Google Support
Share files or apps with Nearby Share · On your Android device, open Files by Google Files Go . · At the top...
Read more >Android 6: cannot share files anymore? - Stack Overflow
Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("image/*"); Uri uri = Uri.fromFile(new File(mFilename)); shareIntent.
Read more >11 easy ways to transfer files from an Android to a PC or Mac
You may need a different one if your phone has the newer USB Type-C-to-Type-C cable and your desktop or laptop doesn't have a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@watchtower314 add below code add app/src/main/AndroidManifest.xml
and in res/xml/filepaths.xml
and path add prefix file://,so result path :
file:///data/user/0/com.appName/cache/123456.pdf
, it will work fine@suwu150 's solution did the trick! Although at first it seemed not to work; it caused a different error that said
failed to find configured root that contains /file:/storage/emulated/0/123456.pdf
but after removing the app from my device and rebuilding, it worked perfectly!Thanks!!