Search code examples
androidfilestoragefile-permissionspermission-denied

Gallery unable to show image


I am storing image file into application path i.e "/data/user/0/app_name". When I tried to open saved image into Gallery via Intent.ACTION_VIEW, its throwing exception like "java.io.FileNotFoundException" and "open failed: EACCES (Permission denied)".

Same thing was working fine when I was storing file on external storage. But due to privacy and security i need to save files into my app folder. For that I have used "getApplicationInfo().dataDir" to get path.

Please suggest what i need to do.

Note: App have below permissions <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

This permission is granted.


Solution

  • If you want to keep the file in private internal memory then use a FileProvider to serve the file.

    Store the file in getFilesDir().