Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Permission denied while it Allowed! access to external storage problem

See original GitHub issue

I tried the sample app on Android 10 (AVD virtual device), and it failed to saving photo on device, “permission denied”, while I Allowed it.

I search and found that this deprecated function is the problem.

I replace it with: File file = new File(this.getExternalFilesDir(DIRECTORY_PICTURES) + File.separator + "" + System.currentTimeMillis() + ".png"); and it works fine, but it save photo in app private folder.

  • I read that android 10 will not give direct access to external storage.

there are some workaround solutions, but I didn’t use it.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

breel93commented, Mar 27, 2020

I just Opened PR about this Issue, My fix: app:manifest.xml


EditImageActivity Replace

 File file = new File(Environment.getExternalStorageDirectory()
                    + File.separator + ""
                    + System.currentTimeMillis() + ".png");


final File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES),
                System.currentTimeMillis() + ".png");

then add this method

//added the photo file to gallery
    private static void galleryAddPic(Context context, String imagePath) {
        Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
        File f = new File(imagePath);
        Uri contentUri = Uri.fromFile(f);

call the method after in saved onSuccess

     public void onSuccess(@NonNull String imagePath) {
        galleryAddPic(EditImageActivity.this, file.getAbsolutePath());  <-- here

I hope this helps someone

nazmussakibsaad102commented, Jun 13, 2020

@breel93 Thanks bro. Helped a lot 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

External Hard Drive Access Denied Error and How to Fix It
Permission Settings: If you don't have permission to access the external hard drive, you're likely to see the “Access is denied” error.
Read more >
External hard drive: “Access is denied” error on Windows 10 ...
To do this, open Disk Management by right-clicking Start and choosing Disk Management. Next, right-click on the inaccessible disk and click ...
Read more >
Permission denied on writing to external storage despite ...
The user will have to explicitly allow access to all files if you want to read files from any source in the device...
Read more >
Access Denied Error or File/Folder Permission Issues on an ...
Access Denied Error or File/Folder Permission Issues on an External Drive · Check My Computer > Tools > Folder Options > View, and...
Read more >
Top 8 Ways to Fix "USB Access Denied" Problem in Windows ...
They often signify that the USB (storage) device has restricted read or write permission. Depending on other symptoms, your "USB access denied" message...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found