[Solved] Captured Image is not storing in android 11

Pritham Bnr Asks: Captured Image is not storing in android 11
I’m unable to store captured image in (getExternalFilesDir(Environment.DIRECTORY_PICTURES)) android 11 device.

I have added uses-permissionandroid:name=”android.permission.MANAGE_EXTERNAL_STORAGE”/ in manifest and all file access also. but it’s not working. please help me out

Code:
            if (!Environment.isExternalStorageManager()) {
                try {
                    val intent = Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION)
                    intent.addCategory("android.intent.category.DEFAULT")
                    intent.data = Uri.parse(String.format("package:%s", applicationContext.packageName))
                    startActivityForResult(intent, 2296)
                } catch (e: Exception) {
                    val intent = Intent()
                    intent.action = Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION
                    startActivityForResult(intent, 2296)
                }
            }
        }

this code is working below android 11 device. but in android 11 file is not creating

File(context.getExternalFilesDir(Environment.DIRECTORY_PICTURES)
                    .toString() + "/" + FolderName )

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.