Hey everyone,
I’ve been migrating some older legacy codebases recently, and honestly, trying to piece together Google's official documentation on Scoped Storage, especially with the Android 13/14 granular permissions, gave me a headache.
I wrote down a cheat sheet to standardize how I handle files now, and thought it might save some of you a few hours of debugging.
Here is the TL;DR on the modern rules:
- READ_EXTERNAL_STORAGE is dead. For API 33+, you have to use granular permissions (READ_MEDIA_IMAGES, READ_MEDIA_VIDEO, READ_MEDIA_AUDIO).
- Go "Zero Permission" if you can. If you just need a user to pick a profile picture, don't ask for manifest permissions. Just use the PhotoPicker (
ActivityResultContracts.PickVisualMedia). - Stop trying to put non-media files in the MediaStore. Use
Context.getExternalFilesDir()for hidden app data, and the Storage Access Framework (SAF) for user-facing documents like PDFs. - Don't forget API 34's
READ_MEDIA_VISUAL_USER_SELECTED. You have to handle partial media access gracefully now without looping permission prompts.
I wrote a much deeper dive into the architecture, including how to fix Environment.getExternalStorageDirectory() crashes, on my technical blog.
If you want the full breakdown, you can read it here: Android Studio Scoped Storage
Hope this helps someone avoid the SecurityExceptions I had to deal with!
Top comments (0)