Coding⏱️ 2 min read📅 2026-06-03
How to Fix: Storage permission error in Marshmallow
Learn how to fix: Storage permission error in Marshmallow.
Quick Answer: Try checking your system settings or restarting.
The error you're experiencing is due to the new security features in Android Marshmallow, which restricts external storage access. To fix this issue, follow these steps:
✅ Best Solutions to Fix It
Method 1: Requesting Runtime Permission
- Step 1: Add the following code to your activity or fragment where you're trying to access external storage:
if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { requestPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE); } else { // You can proceed with writing to external storage here }Method 2: Declaring Permission in AndroidManifest.xml
- Step 1: Add the following line to your
<application>tag in your AndroidManifest.xml file:
<uses-permission android:name= ❓ Frequently Asked Questions
Step 1: Add the following code to your activity or fragment where you're trying to access external storage:
Step 1: Add the following line to your <application> tag in your AndroidManifest.xml file:
🛠️ Related Fixes
How to Fix: Stuck in tutorial hell after 4 years: How do I b
Fix Stuck in tutorial hell after 4 years: How do I bui. Practice build
How to Fix: Trying to sync mutliple audio tracks to a movie
Fix Trying to sync mutliple audio tracks to a movie bu. Consider using
How to Fix: Failed to merge latest branches from upstream re
Fix Failed to merge latest branches from upstream repo. Try running 'g