Search code examples
androidpermission-denied

How to grant permission to files not owned by application


When trying to send files not created by my app to Firebase Storage, I get an exception with the message "/path/to/the/file permission denied".

However, when I create in my code a file in the internal directory of my app (/data/data/package_name/files/) and send it to the Firebase storage it works.

How to send other files located elsewhere in the internal storage without troubles ?


Solution

  • You should add permission in the manifest and also check and ask for permission to access storage in the runtime.

    In manifest, add:

    <uses-permission android:name="ANDROID.PERMISSION.WRITE_EXTERNAL_STORAGE" />
    

    For runtime permissions, I hope this library will help you. https://github.com/nabinbhandari/Android-Permissions