Android 外部存储状态的不同状态

Android 外部存储状态的不同状态,android,Android,解释在何种情况下(例如:手机作为媒体连接到计算机,SD卡未安装),将满足以下条件 if (Environment.MEDIA_MOUNTED.equals(state)) { // Can read and write the media mExternalStorageAvailable = mExternalStorageWriteable = true; } else if (Environment.MEDIA_MOUNTED_READ_ONLY.e

解释在何种情况下(例如:手机作为媒体连接到计算机,SD卡未安装),将满足以下条件

if (Environment.MEDIA_MOUNTED.equals(state)) {
        // Can read and write the media
        mExternalStorageAvailable = mExternalStorageWriteable = true;
    } else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
        // Can only read the media
        mExternalStorageAvailable = true;
        mExternalStorageWriteable = false;
    } else {
        // Can't read or write
        mExternalStorageAvailable = mExternalStorageWriteable = false;
    }   
这将检查外部存储器是否可用于读写。
getExternalStorageState()
方法返回您可能要检查的其他状态,例如媒体是否正在共享(连接到计算机)、是否完全丢失、是否已被严重删除等。当应用程序需要访问媒体时,您可以使用这些状态通知用户更多信息

环境。媒体已安装

Check Storage state if the media is present and mounted at its mount point with read/write access. 
It will be true if the SD card is available.
环境。媒体安装的只读

It will true if sdcard is available and its Read only.

如果您的SD卡是只读的。并且您尚未提供从设备设置连接到系统时访问它的权限。
It will true if sdcard is available and its Read only.