Android N FileUriExposedException

Posted: December 27, 2016 in Android, Technology
Tags: , , , , , , ,

Hello droids!

Here is another quick solution for not letting your app get crash in Nougat devices.

Mostly crash occurs with file permission while taking photo or selecting image from the gallery in Nougat devices.

In general you will get FileUriExposedException.

How to solve this issue?
Here is the quick solution, you need to follow 3 – 4 steps and voila you’re done!

Step 1 : provider_paths.xml
Create provider_paths.xml to /res/xml directory

<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="">
    <external-path name="external_files" path="."/>

Step 2 : AndroidManifst file update
Open your manifest file and add below tags in between <application> </application> tags.



Step 3 : Application class edit
Hope you are aware of how to declare application class. If not do comment on this post, I’ll let you know.

public void onCreate() {
    //Allowing Strict mode policy for Nougat support
    StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();

Now, you are ready to access URI files from nougat enabled devices.
Don’t forget to add appropriate permissions to your manifest file for camera and external storage.

Have fun! Keep coding!

  1. Bryan Domo says:

    Very Hopeful,
    I thank you with all my strength 🙂

  2. gerald r. pagobo says:

    Thanks a lot man.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s