Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trouble Obtaining User Permissions for Internal Storage Access in Android App

I have an Android application, and I want to get the user's permission to read and write to the internal storage. The SDK specifications are: min: 23, target: 35. However, it's not working. Does anyone know why?

i use <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

but not working

like image 448
Bhoon Hoki Avatar asked Sep 16 '25 23:09

Bhoon Hoki


1 Answers

WRITE_EXTERNAL_STORAGE is deprecated for Android 11+ (API 30+). If you want to access the storage then use scoped storage, for sepcific use cases you can follow: • For app-specific files: context.getExternalFilesDir(). • For shared media: Use MediaStore. • For file picking: Use Storage Access Framework (SAF) with Intent.ACTION_OPEN_DOCUMENT.

Add runtime permissions for READ_MEDIA_IMAGES, READ_MEDIA_VIDEO, or READ_MEDIA_AUDIO for API 33+.

Avoid android:requestLegacyExternalStorage unless targeting API < 30.

like image 152
Usman Khan Avatar answered Sep 19 '25 15:09

Usman Khan