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

FileProvider.getUriForFile is throwing StringIndexOutOfBoundsException

First thing to mention, answers to the question here do not help. The source code looks like the following: Intent intent = new Intent("com.mycompany.action.PICK_FILE"); String authority = "com.mycompany.fileprovider"; File file =…
Viktor Brešan
  • 5,293
  • 5
  • 33
  • 36
6
votes
0 answers

How to use content URIs for ACTION_VIEW in Nougat?

I have an app that generates video files, which can be placed in the internal storage or the SD card, and need to be opened by the user's preferred video player app via Intent.ACTION_VIEW. The app works as intended when targeting API 22, but I'm…
PM4
  • 624
  • 1
  • 5
  • 18
6
votes
1 answer

Android Fileprovider: Failed to find configured root that contains

I have created an app, that creates gpx files. Everything is working fine except for the sharing. Therefore I have created a File Provider. You can see it's configuration below. The Provider is working fine on my android device running Android 8.0.0…
Mojo
  • 377
  • 6
  • 18
6
votes
0 answers

Using Firebase and FileProvider with Build Variants

I am using build variants with Firebase and my application also needs to use FileProvider for sharing app files to be opened in 3rd party apps. But when I am trying to send the URI in the intent, the app crashes giving following…
Sumit Jain
  • 1,100
  • 1
  • 14
  • 27
6
votes
3 answers

Android 7 nougat, how to get the file path from uri of incoming intent?

FileProvider:- Setting up file sharing I know that change the file policy in android nougat. The wanted app that file share to other apps generate the uri by FileProvider. The uri format is…
6
votes
1 answer

FileProvider.getUriForFile vs Uri.fromFile - is there other difference but permissions

In my Andoroid app I want to let the user send a file that my app has generated using whatever sending method the user prefers (e.g. Email, Skype, Viber, Bluetooth, etc) I am using Intent.ACTION_SEND as follows: File readF = new…
Jeni
  • 1,088
  • 12
  • 30
6
votes
2 answers

How to open an APK file for all Android versions

Background So far, there was an easy way to install an APK file, using this intent: final Intent intent=new Intent(Intent.ACTION_VIEW) .setDataAndType(Uri.fromFile(apkFile), "application/vnd.android.package-archive"); But, if your…
android developer
  • 114,585
  • 152
  • 739
  • 1,270
6
votes
1 answer

Android 7.0 Notification Sound from File Provider Uri not playing

I'm changing my app code for supporting Android 7, but in my NotificationCompat.Builder.setSound(Uri) passing the Uri from FileProvider the Notification don't play any sound, in Android 6 using the Uri.fromFile() worked properly. The mp3 file is…
6
votes
2 answers

Android taking picture with FileProvider

I'm taking a picture on Android Nougat with FileProvider, that's my code
Ihor Klimov
  • 898
  • 4
  • 15
  • 23
6
votes
1 answer

FATAL EXCEPTION: ThumbnailManager-1 while sharing images to Intent

I got following Exception while sharing images using FileProvider. Following is the code I used to. { ArrayList files = new ArrayList(); files.add(getImageUriFromCache(context,bitmap,fileName)); } private void…
6
votes
2 answers

Share Assets Using fileprovider

Followed https://developer.android.com/training/secure-file-sharing/index.html and able to share files in the internal directory(/data/data/package/files/xxx/) of app to client app using fileprovider. How to share the files in assets folder(instead…
6
votes
1 answer

Sharing cached images using FileProvider

I have an app that uses Universal Image Loader to download photos from the internet, cache them to data/data/com.myapp/cache and display in ImageViews. I also wanted to add sharing (WhatsApp, Facebook, Instagram, Dropbox etc.) to my app, so I tried…
5
votes
1 answer

java.io.FileNotFoundException open failed: ENOENT (No such file or directory)

I have a temp file that is made for creating an image from a cropping library and I can see the file in Device File Explorer but when I try to open the file I get this error: java.io.FileNotFoundException:…
Eman
  • 1,093
  • 2
  • 26
  • 49
5
votes
3 answers

How to retrieve and open PDF file saved to downloads through MediaStore API in Android?

I am downloading a PDF file from a server and passing the response body bytestream into the function below, which is storing the PDF file successfully in the user downloads folder. @RequiresApi(Build.VERSION_CODES.Q) fun saveDownload(pdfInputStream:…
y390
  • 121
  • 1
  • 5
5
votes
3 answers

Unable to programmatically attach file to an email intent using a FileProvider

I'm creating an email intent and attaching a file (using a FileProvider) but the Gmail client reports "impossible to attach the file". I had this working previously but it's now broken. I didn't change my code (that I'm aware of) but have updated…
T Clulow
  • 74
  • 7