So I'm working on an app where I'm taking a photo and trying to save it to the apps internal storage. I'm having issues with the fileprovider. I have looked at many many of the questions asked on stack overflow, but would like to get a more in detail explanation if possible.
I also followed googles example and it gives me the following error. https://developer.android.com/training/camera/photobasics
Failed to find configured root that contains /storage/emulated/0/Android/data/com.myapp.debug/files/Pictures/JPEG_20180427_095752_2090822261.jpg
Here is the code i have whenever i follow Google's example.
<provider
android:name=".application.blinkupregistration.postworkphotos.PostWorkPhotosFileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>
In my code.
Uri photoURI = FileProvider.getUriForFile(this, BuildConfig.APPLICATION_ID + ".provider", photoFile);
For the two above, I also tried to hardcode com.myapp.provider into the authorities and getUriForFile method. Also did getpackageName() for the getUriForFile method. But these did not change much. I think the main issue is the paths.
Tried the following paths by using Google's example,
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="post_work_photos" path="Android/data/${applicationId}/files/Pictures" />
</paths>
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="post_work_photos" path="Android/data/com.myapp/files/Pictures" />
</paths>
I get this to work whenever I change my paths.xml to the following.
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="post_work_photos" path="." />
</paths>
But I do not understand why it works with the period. I also do not know if this the correct practice, which is my main concern.
If anyone can help me out, then that would be great. Thanks.