I am trying to implement a FileProvider to allow me to share local, private images with email and other apps. I have been following the instructions of the Android Developers Guide and get down to where I have to use the "getUriForFile" function and Eclipse tells me I have to create the method. I was under the impression this should be in the android.support.v4.content package and it is in the Referenced Libraries for the app, but it is not there.
I have added the following to my Manifest:
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.gelbintergalactic.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/my_paths" />
</provider>
I have created this xml file:
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<files-path name="files" path="." />
</paths>
But when I get to this point in my code I am stymied:
Uri contentUri = getUriForFile(this, "com.gelbintergalactic.fileprovider", newfile);
What step am I missing?
Yes, instructions in dev guide are not the greatest. getUriForFile()
is a static method of the FileProvider class so you need to do:
Uri contentUri =
FileProvider.getUriForFile(this, "com.gelbintergalactic.fileprovider", newfile);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With