Check if the SDCard is present, boolean is always true

前端 未结 7 1997
故里飘歌
故里飘歌 2020-11-29 05:42

In my splash screen, I want to check if the phone has a SDCard. The Boolean statement is beneath:

    Boolean isSDPresent = android.os.Environment.getExterna         


        
7条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-29 05:54

    I've found that phones, like the Galaxy phones from Samsung, have /mnt/sdcard point to internal memory and not the external SD card as expected.

    You can know if the path returned by Environment.getExternalStorageDirectory() is actually the external SD card with a call to Environment.isExternalStorageRemovable()

    Just wanted to add from the docs for getExternalStorageDirectory() this important note:

    Note: don't be confused by the word "external" here. This directory can better be thought as media/shared storage. It is a filesystem that can hold a relatively large amount of data and that is shared across all applications (does not enforce permissions). Traditionally this is an SD card, but it may also be implemented as built-in storage in a device that is distinct from the protected internal storage and can be mounted as a filesystem on a computer.

提交回复
热议问题