Questions tagged [android-fileprovider]

FileProvider is an extension of Android's ContentProvder class, which supports easy sharing of private files between apps.

FileProvider supports easy sharing of private files between Android apps. When paired with features like grantUriPermission(String, Uri, int) or FLAG_GRANT_READ_URI_PERMISSION, this provider ensures that receiving apps can always open the underlying file.

Apps should generally avoid sending raw filesystem paths across process boundaries, since the receiving app may not have the same access as the sender. Instead, apps should send Uri backed by a provider like FileProvider.

Resources:

679 questions
5
votes
1 answer

Is it possible to provide a zipped file in FileProvider, of a file that doesn't really exist?

Background I wish to be able to share some files (via a send intent) as a single compressed file, via FileProvider, but without actually creating this file. For the intent, all you do is add the ArrayList as a parameter, as such: ArrayList
android developer
  • 114,585
  • 152
  • 739
  • 1,270
5
votes
4 answers

Unable to get provider androidx.core.content.FileProvider ClassNotFoundException when trying to build an Android Plugin for Unity

I am trying to build an android plugin for unity3d that simply share a screenshot to another app via the FileProvider. I migrated my project to androidx. I have used androidx.core.content.FileProvider class. My app crashes whenever I launch it, with…
5
votes
2 answers

FileProvider.getUriForFile is causing StringIndexOutOfBoundsException

I have updated my project to implement Providers. The whole implementations seem right, but I am receiving a StringIndexOutOfBoundsException exception inside FileProvider class. In my case, an Intent is created, in which, the user will choose…
GuilhermeFGL
  • 2,891
  • 3
  • 15
  • 33
5
votes
0 answers

Why is my camera intent working? I thought Nougat was supposed to fix this security issue?

Everything I'm seeing says that you need to add a section into the AndroidManifest, and you need to refer to an XML resource file that says the external file path you want for the image. I'm doing neither of those but the code snippet I…
andrdoiddev
  • 349
  • 1
  • 3
  • 15
5
votes
0 answers

Android - How to access the File from a ParcelFileDescriptor?

According to the FileProvider documentation the fileProvider.openFile() method returns a new ParcelFileDescriptor with which you can access the file. I have looked in ParcelFileDescriptor, but I cannot see how to access the File. So how do I…
ban-geoengineering
  • 18,324
  • 27
  • 171
  • 253
5
votes
1 answer

How to handle Unable to decode stream: java.io.FileNotFoundException: on using FileProvider (No such file or directory)

Am trying to support Nougat by getting rid of FileUriExposedException.When I use Uri.fromFile(gettheImageFilehere()) method I successfully get the image path file:///storage/emulated/0/DCIM/Camera/IMG_20170308_171951.jpg When I use…
GotaloveCode
  • 994
  • 1
  • 13
  • 30
5
votes
1 answer

java.lang.IllegalArgumentException: Failed to find configured root that contains /storage/emulated/0/Pictures

I'm trying to share file via intent for instagram , but i realized that on API 24++, i can't just share the URI to other app without giving it permission. Following this…
fahmi sidik
  • 53
  • 1
  • 6
5
votes
3 answers

Android: IllegalArgumentException: Failed to find configured root that contains /data/data/

Just getting into the Glide image loading library for Android. Working with code from here: https://github.com/bumptech/glide/issues/459 Full project here: https://github.com/mhurwicz/glide02 I'm getting the following exception when I run the app…
user1147171
  • 1,213
  • 3
  • 14
  • 22
5
votes
2 answers

App crashes after reinstall on emulator since FileProvider Class was not found

When I run the app on the emulator it always works on the first try. But when the app is already installed on the emulator it often results in a crash during the start of the app. This behavior started to occur with Android Studio 2.0. It does not…
5
votes
1 answer

PackageManager#installPackage doesn't work for Android N

When using build tools version 24 and Android device with N image (npd56n) I'm unable to install package using PackageManager#installPackage. When URI with the file: scheme is passed to the method, -3 is returned, I assume it is the…
5
votes
1 answer

Using Content URI with ACTION_VIDEO_CAPTURE

I'm currently using Content URIs on my file provider to retrieve camera images returned by a ACTION_IMAGE_CAPTURE intent. This works fine. For some strange reason, the same call doesn't work when attempting to retrieve a video file from the camera. …
5
votes
1 answer

Failed to find configured root that contains

I'm getting the following error : 05-29 01:08:02.924: E/AndroidRuntime(5447): FATAL EXCEPTION: IntentService[com.sample.muzeitest.MuzeiClass] 05-29 01:08:02.924: E/AndroidRuntime(5447): java.lang.IllegalArgumentException: Failed to find configured…
t0s
  • 1,201
  • 5
  • 19
  • 28
4
votes
7 answers

Android: FileProvider.getUriForFile reading MediaStore-generated file?

TL;DR I wanna get(read/generate) file Uri -- with path like below -- by FileProvider, but don't know how: val file = File("/external/file/9359") // how do I get its Uri then? All I know was FileProvider.getUriForFile method, but it throws…
Samuel T. Chou
  • 521
  • 6
  • 31
4
votes
1 answer

Migration from File Api to Storage Access Framework (SAF) in Android

Due to Android 11 and scoped storage I have to start work with Storage Access Framework (SAF), but I have lot of source code that works with File API. Question 1: Do I have to rewrite everything to work with DocumentFile? Pseudo use case: User…
4
votes
1 answer

Can not save PDF file with FileProvider and external PDF Editor

I have various PDFs in the Android/data/packagename folder of my app and need to be able to edit them. The opening via e.g. Adobe Reader works without any problems and the FileProvider works so far. When I close the PDF Editor, the changed file is…
TPower
  • 41
  • 2