Given that at some point I have a URI given to me by some external library, and all FileProvider setup is done correctly (and the URI has been granted read/write permissions), how could I get the path to image on disk that the URI is pointing to?
Let's suppose that the image file is stored at /sdcard/XYZAppFolder/file.jpg
.
While in debug I can see the string of the URI:
content://<applicationID>.provider/<virtualfolder>/file.jpg
But when trying to perform a query via ContentResolver, I get index -1:
Cursor cursor = contentResolver.query(contentURI, null, null, null,
cursor.moveToFirst();
int idx = cursor.getColumnIndex(Images.ImageColumns.DATA);
<paths>
<external-path
name="virtualfolder"
path="VISUAPP" />
</paths>
Manifest:
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
Any other way to get the absolute path?