i am following this tutorial https://developer.android.com/training/camera/photobasics in order to capture an image
i added the following file to xml folder
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="my_images"
path="Android/data/mypackage/files/Pictures" />
The capturing of the image using the above file works perfectly as expected but if i used @string resource as as shown below
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="my_images"
path="@string/mypath" />
<string name="mypath">Android/data/mypackage/files/Pictures</string>
i am getting the following exception
Failed to find configured root that contains /storage/emulated/0/Android/data/mypackage/files/Pictures/IMG_20181018_134824_5769070663217749604.jpg
it workes perfectly if i don't use @string resource ,i need to use with string resources since i want to have different string when building app with gradle using build types
EDIT file provider in manifest file
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@string/mypath">
</meta-data>
</provider>
i need to use with string resources
You cannot use string resources in arbitrary locations, such as in FileProvider
metadata.
i want to have different string when building app with gradle using build types
Then have different xml
resources per build type, with different FileProvider
metadata. IOW, replace the entire file, not a string within the file.