I'm using FileProvider in my app, when I take a picture from the app is stored there. also my app have a different application id for debug and release builds
I have defined my file provider like this
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="@string/authority_file_provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
the value of @string/authority_file_provider
will turn into:
and my @xml/file_paths
is defined like
<?xml version="1.0" encoding="utf-8"?>
<paths>
<external-path name="my_images" path="Android/data/com.rkmax.myapp/files/Pictures" />
</paths>
if I try to changes to something like Pictures
or files/Pictures
my app fails
Failed to find configured root that contains/storage/emulated/0/Android/data/com.rkmax.myapp.debug/files/Pictures/20161112_073128-251269360.jpg
How I define a relative path in the file provider paths?
Every Android app has a unique application ID that looks like a Java package name, such as com. example. myapp. This ID uniquely identifies your app on the device and in Google Play Store. Once you publish your app, you should never change the application ID.
To make FileProvider work follow these three steps: Define the FileProvider in your AndroidManifest file. Create an XML file that contains all paths that the FileProvider will share with other applications. Bundle a valid URI in the Intent and activate it.
For your particular case, replace:
<external-path name="my_images" path="Android/data/com.rkmax.myapp/files/Pictures" />
with:
<external-files-path name="my_images" path="Pictures" />
This will require 24.0.0 or higher of the support libraries, IIRC.
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