Some Android devices treat Internal Storage as SD Cards and External Storage as EXTSD

前端 未结 3 1912
离开以前
离开以前 2021-02-14 03:27

I have a bunch of Android devices from different vendors.

Some of them attach /mnt/sdcard to internal storage and /mnt/extsd to external storage(Scenar

相关标签:
3条回答
  • 2021-02-14 03:57

    On a rooted device, you can change your /system/etc/permissions/platform.xml to "fix" the permissions issue. The following worked for me:

    • adb pull /system/etc/permissions/platform.xml
    • Modify platform.xml such that media_rw is included in the WRITE_EXTERNAL_STORAGE permission like this:

      <permission name="android.permission.WRITE_EXTERNAL_STORAGE" >
         <group gid="sdcard_rw" />
         <group gid="media_rw" />
      </permission>
      
    • adb push platform.xml /system/etc/permissions/platform.xml

    • Restart Device
    0 讨论(0)
  • 2021-02-14 04:10
    Environment.getExternalStorageState() returns path to internal SD mount point like "/mnt/sdcard"
    

    Environment.getExternalStorageDirectory() refers to whatever the device manufacturer considered to be "external storage". On some devices, this is removable media, like an SD card. On some devices, this is a portion of on-device flash. Here, "external storage" means "the stuff accessible via USB Mass Storage mode when mounted on a host machine", at least for Android 2.x and above.

    But the question is about external SD. How to get a path like "/mnt/sdcard/external_sd" (it may differ from device to device)?
    

    Android has no concept of "external SD", aside from external storage, as described above.

    If a device manufacturer has elected to have external storage be on-board flash and also has an SD card, you will need to contact that manufacturer to determine whether or not you can use the SD card (not guaranteed) and what the rules are for using it, such as what path to use for it.

    0 讨论(0)
  • 2021-02-14 04:14

    The only work around I've found so far to get write access on the device is rooting the device :(

    Samsung provides a work around with a manifest entry

    More details are available in the following links

    http://www.xda-developers.com/android/android-3-2-code-inadvertently-preventing-write-access-to-external-storage/

    and

    http://www.chainfire.eu/articles/113/Is_Google_blocking_apps_writing_to_SD_cards_/

    Excerpts:

    It would seem that Google has a bug in their AOSP code that was introduced around Android 3.2, which affects how the OS handles USB Storage and can prevent write access to SD cards and USB sticks. XDA Elite Recognized Developer, Senior Moderator, and News Writer Chainfire sums up the issue in his blog post:

    "In the past, an app would request the “WRITE_EXTERNAL_STORAGE” permission, which would grant write access to all external storages (user/group “sdcard_rw“). This has apparently been changed to only grant write access to the primary external storage. A second permission has been introduced called “WRITE_MEDIA_STORAGE“, which would grant access to the other external storages (user/group “media_rw“).

    The problem is, a third party will not actually be granted this permission, only system apps and apps provided by the device manufacturer will normally be granted this permission. There are exceptions, apparently on some devices third party apps will be granted this permission, but according to the AOSP sources, they’re certainly not supposed to."

    0 讨论(0)
提交回复
热议问题