adb shell appops set --uid PACKAGE_NAME MANAGE_EXTERNAL_STORAGE allow
ประกาศของ Google Play
ส่วนนี้จะแสดงประกาศสำหรับนักพัฒนาแอปที่เผยแพร่แอปใน Google Play
Google Play Store ได้อัปเดต
นโยบาย
เพื่อประเมินแอปที่กำหนดเป้าหมายเป็น Android 11 (API ระดับ 30) ขึ้นไปและขอ
สิทธิ์เข้าถึงไฟล์ทั้งหมดผ่านสิทธิ์ MANAGE_EXTERNAL_STORAGE เพื่อจำกัดการเข้าถึงพื้นที่เก็บข้อมูลที่ใช้ร่วมกันในวงกว้าง นโยบายนี้
มีผลบังคับใช้ตั้งแต่เดือนพฤษภาคม 2021
เมื่อแอปกำหนดเป้าหมายเป็น Android 11 ขึ้นไปและประกาศสิทธิ์
MANAGE_EXTERNAL_STORAGE Android Studio จะแสดงคำเตือน Lint ที่
ปรากฏในรูปที่ 1 คำเตือนนี้ช่วยเตือนว่า Google Play Store มี
นโยบายที่จำกัดการใช้สิทธิ์
รูปที่ 1 คำเตือน Lint ใน Android Studio ที่ช่วยเตือนนักพัฒนาแอปเกี่ยวกับนโยบายของ Google Play ที่เกี่ยวข้องกับMANAGE_EXTERNAL_STORAGE
สิทธิ์
ขอMANAGE_EXTERNAL_STORAGEสิทธิ์เฉพาะเมื่อแอปของคุณไม่สามารถใช้ API ที่เคารพความเป็นส่วนตัวมากขึ้นอย่างมีประสิทธิภาพ เช่น Storage
Access Framework หรือ Media
Store API การใช้งานสิทธิ์ของแอปต้องอยู่ในการใช้งานที่อนุญาต และต้องเชื่อมโยงโดยตรงกับฟังก์ชันการทำงานหลักของแอป หากแอปของคุณมีกรณีการใช้งานที่คล้ายกับกรณีใดกรณีหนึ่งต่อไปนี้ แอปก็น่าจะขอMANAGE_EXTERNAL_STORAGEสิทธิ์ได้
[[["เข้าใจง่าย","easyToUnderstand","thumb-up"],["แก้ปัญหาของฉันได้","solvedMyProblem","thumb-up"],["อื่นๆ","otherUp","thumb-up"]],[["ไม่มีข้อมูลที่ฉันต้องการ","missingTheInformationINeed","thumb-down"],["ซับซ้อนเกินไป/มีหลายขั้นตอนมากเกินไป","tooComplicatedTooManySteps","thumb-down"],["ล้าสมัย","outOfDate","thumb-down"],["ปัญหาเกี่ยวกับการแปล","translationIssue","thumb-down"],["ตัวอย่าง/ปัญหาเกี่ยวกับโค้ด","samplesCodeIssue","thumb-down"],["อื่นๆ","otherDown","thumb-down"]],["อัปเดตล่าสุด 2025-08-27 UTC"],[],[],null,["The majority of apps that require shared storage access can follow the best\npractices for [sharing media\nfiles](/training/data-storage/use-cases#share-media-all) and [sharing non-media\nfiles](/training/data-storage/use-cases#sharing-non-media-files). However, some\napps have a core use case that requires broad access to files on a device, but\ncan't access them efficiently using the privacy-friendly storage best practices.\nAndroid provides a special app access called *all-files access* for these\nsituations.\n\nFor example, an anti-virus app's primary use case might require regular scanning\nof many files across different directories. If this scanning requires repeated\nuser interactions to select directories using the system file picker, it\nprovides a poor user experience. Other use cases---such as file manager apps,\nbackup and restore apps, and document management apps---require similar\nconsiderations.\n\nRequest all-files access\n\nAn app can request all-files access from the user by doing the following:\n\n1. Declare the [`MANAGE_EXTERNAL_STORAGE`](/reference/android/Manifest.permission#MANAGE_EXTERNAL_STORAGE) permission in the manifest.\n2. Use the [`ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION`](/reference/android/provider/Settings#ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION) intent action to direct users to a system settings page where they can enable the following option for your app: **Allow access to manage all files**.\n\nTo determine whether your app has been granted the `MANAGE_EXTERNAL_STORAGE`\npermission, call\n[`Environment.isExternalStorageManager()`](/reference/android/os/Environment#isExternalStorageManager()).\n\nOperations permitted by MANAGE_EXTERNAL_STORAGE\n\nThe `MANAGE_EXTERNAL_STORAGE` permission grants the following:\n\n- Read and write access to all files within [shared\n storage](/training/data-storage/shared).\n\n | **Note:** The `/sdcard/Android/media` directory is part of shared storage.\n- Access to the contents of the\n [`MediaStore.Files`](/reference/android/provider/MediaStore.Files) table.\n\n- Access to the root directory of both the USB on-the-go (OTG) drive and the SD\n card.\n\n- Write access to all internal storage directories except\n `/Android/data/`, `/sdcard/Android`, and most subdirectories of\n `/sdcard/Android`. This write access includes [direct file\n path](/training/data-storage/shared/media#direct-file-paths) access.\n\n Apps that are granted this permission still can't access the [app-specific\n directories](/training/data-storage/app-specific) that belong to other apps,\n because these directories appear as subdirectories of `Android/data/` on a\n storage volume.\n\nWhen an app has the `MANAGE_EXTERNAL_STORAGE` permission, it can access these\nadditional files and directories using either the\n[`MediaStore`](/reference/android/provider/MediaStore) API or [direct file\npaths](/training/data-storage/shared/media#direct-file-paths). When you use the\n[Storage Access Framework](/training/data-storage/shared/documents-files),\nhowever, you can only access a file or directory if you can do so without\nhaving the `MANAGE_EXTERNAL_STORAGE` permission.\n\nInvoke another app's storage management activity\n\nOn Android 12 (API level 31) and higher, apps that have both the\n[`MANAGE_EXTERNAL_STORAGE`](/reference/android/Manifest.permission#MANAGE_EXTERNAL_STORAGE)\npermission and the\n[`QUERY_ALL_PACKAGES`](/reference/android/Manifest.permission#QUERY_ALL_PACKAGES)\npermission---such as file management apps---can use the\n[`getManageSpaceActivityIntent()`](/reference/android/os/storage/StorageManager#getManageSpaceActivityIntent(java.lang.String,%20int))\nto send users to another app's [custom space management\nactivity](/training/data-storage/app-specific#create-storage-management-activity).\n\nThe `getManageSpaceActivityIntent()` method takes in a package name and a\nrequest code, and it returns one of the following:\n\n- A [`PendingIntent`](/reference/android/app/PendingIntent), if the app with the specified package name has defined a custom \"manage space\" activity. The file management app that called the `getManageSpaceActivityIntent()` method can then invoke the returned intent to send users to the custom activity.\n- `null`, if the app with the specified package name doesn't define a \"manage space\" activity.\n\nEnable MANAGE_EXTERNAL_STORAGE for testing\n\nTo explore how the `MANAGE_EXTERNAL_STORAGE` permission affects your app, you\ncan enable the permission for testing. To do so, run the following\ncommand on the machine that's connected to your test device: \n\n```\nadb shell appops set --uid PACKAGE_NAME MANAGE_EXTERNAL_STORAGE allow\n```\n\nGoogle Play notice\n\nThis section provides a notice for developers who publish apps on Google Play.\n\nTo limit broad access to shared storage, the Google Play store has [updated its\npolicy](https://support.google.com/googleplay/android-developer/answer/10467955)\nto evaluate apps that target Android 11 (API level 30) or higher and request\nall-files access through the `MANAGE_EXTERNAL_STORAGE` permission. This policy\nis in effect as of May 2021.\n\nWhen your app targets Android 11 or higher and it declares the\n`MANAGE_EXTERNAL_STORAGE` permission, Android Studio shows the lint warning that\nappears in figure 1. This warning reminds you that the Google Play store has a\npolicy that limits usage of the permission.\n**Figure 1.** Lint warning in Android Studio that reminds developers about the Google Play policy regarding the `MANAGE_EXTERNAL_STORAGE` permission.\n\nRequest the `MANAGE_EXTERNAL_STORAGE` permission only when your app\ncan't effectively make use of the more privacy-friendly APIs, such as the [Storage\nAccess Framework](/training/data-storage/shared/documents-files) or the [Media\nStore API](/training/data-storage/shared/media). Your app's usage\nof the permission must fall within permitted uses and must be directly tied to\nthe core functionality of the app. If your app includes a use case\nsimilar to any of the following, it's likely that it can request the\n`MANAGE_EXTERNAL_STORAGE` permission:\n\n- File managers\n- Backup and restore apps\n- Anti-virus apps\n- Document management apps\n- On-device file search\n- Disk and file encryption\n- [Device-to-device data migration](/guide/topics/data/testingbackup#TestingTransfer)"]]