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
4
votes
1 answer

Intent ACTION_OPEN_DOCUMENT_TREE doesn't seem to return a real path to drive

I'm trying to read files from a USB storage device connected to my Google Pixel. I'm currently using this method to select the path of the drive so I can query it for its contents private static final String TAG = "MainActivity"; private static…
Carpetfizz
  • 8,707
  • 22
  • 85
  • 146
4
votes
1 answer

Android FileProvider cannot find file

I am relatively new to Android programming and followed several different tutorials. The target was to copy a pdf-file from the assets folder to the external storage and then open an Intent when a button is pressed to open a PDF-Viewer. I tried to…
4
votes
2 answers

FileProvider is opening a PDF but it is blank. Why?

I have a FileProvider in my app, and it pretends like it is working but the files it opens are blank. I have confirmed that the file is already on the device in the specified directory and is not blank, but when I try to open it from inside my app…
4
votes
1 answer

How to get orientation of image file, which was taken from FileProvider class?

Background Targeting API 24 or above, instead of using a simple "Uri.fromFile" command, developers need to use FileProvider (or their own ContentProvider), in order to let other apps to access the app's files. The problem I try to open a camera app…
android developer
  • 114,585
  • 152
  • 739
  • 1,270
4
votes
1 answer

Get file path from Uri created via FileProvider

I use this method for getting file path from Uri https://github.com/iPaulPro/aFileChooser/blob/master/aFileChooser/src/com/ipaulpro/afilechooser/utils/FileUtils.java#L257 But it throw exception ("_data" column not found) when I pass Uri created such…
Nickolay Savchenko
  • 1,474
  • 16
  • 28
4
votes
0 answers

Fileprovider doesn't work for image capture

i've spent a lot of time trying to find a solution. I tried getExternalStoragePublicDirectory() and getExternalFilesDir() and many other things. But onActivityResult still brings error resultCode. It works when I switch from fileProvider to…
Alex
  • 41
  • 1
  • 2
4
votes
1 answer

How to share files from any path using a FileProvider?

My app allows the user to download some content and store it in the folder of his choice. I want to create a ContentProvider to share those files, but I don't know how to do that when the downloaded files are stored outside of the app default…
user1026605
  • 1,633
  • 4
  • 22
  • 58
4
votes
0 answers

Google+ Photos ACTION_VIEW, FLAG_GRANT_PERSISTABLE_URI_PERMISSION Exception

In my app I have internal files that I would like to be able to open in external viewers depending on file type. I have a FileProvider set up like the following in the application manifest:
4
votes
1 answer

How to get list of files using FileProvider

A'm working on Android project. I need to provide ContentProvider to provide access to some directory. FileProvider it is good solution for me. Is it possible to retrieve list of files in directory using FileProvider?
Misha
  • 433
  • 4
  • 10
4
votes
1 answer

Android photo sharing with FileProvider

I have read all the answer about this argument but I receive always an error of the application that receive my photo. The only way that worked for me, for all application, was this (It works because sd card files are public to all…
Marco Di Scala
  • 424
  • 1
  • 7
  • 18
3
votes
1 answer

FileProvider class not found exception

I am getting following error with android 10. Although i tried with my device having android 10, everything is working fine but Google crashlytics showing number of crash. Fatal Exception: java.lang.RuntimeException Unable to get provider…
Deepak
  • 142
  • 5
3
votes
0 answers

Difference between FileProvider.getUriForFile and Uri.Parse() in Kotlin Android Studio

can anyone please help me with the difference between FileProvider.getUriForFile and Uri.Parse() in Kotlin Android Studio? I am working on a code in Kotlin to create a excel file and share it on various apps like Gmail, Whatsapp, etc. My issue…
S. B.
  • 186
  • 1
  • 12
3
votes
0 answers

Android 11 - Intent Image attachment not working

Another new breaking changes for Android 11, attaching image is no longer working with Intent FileProvider XML
Bitwise DEVS
  • 2,858
  • 4
  • 24
  • 67
3
votes
1 answer

What is com.google.android.apps.nbu.files.provider/2?

I've opened pdf file from different sources and got this Intents: File manager (Google Files) -> Internal storage -> Download: Intent { act=android.intent.action.VIEW…
3
votes
1 answer

Android 11: Primary directory (invalid) not allowed for content://media/external/file allowed directories are [Download, Documents]

I am trying to create PDF file from base64 string. Because of Storage Update in Android 11, I have to change my code but I'm getting following error in Android 11 devices: java.lang.IllegalArgumentException: Primary directory (invalid) not allowed…