我们如何区分闪存和SD卡内存之间? [英] How we differentiate between flash memory and SD card memory?

查看:156
本文介绍了我们如何区分闪存和SD卡内存之间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一些Android设备有内置闪存,我们可以检查这个内存 Environment.getExternalStorageDirectory()。但是,当我们插入SD卡,则系统区分这两个与 /存储/ sdcard0 /存储/ sdcard1

Some android devices has built-in flash memory, and we can check this memory at Environment.getExternalStorageDirectory(). But, when we insert an SD card, then the system differentiates these two with /storage/sdcard0 and /storage/sdcard1.

我不知道是否 /存储/ sdcard0 是闪存或SD卡存储。任何人都可以提供任何解释,哪个是哪个?

I am not sure whether /storage/sdcard0 is flash memory or SD card memory. Could anyone provide any explanation as to which is which?

推荐答案

使用方法 Environment.isExternalStorageRemovable()来确定它是否是一个可移动的SD卡或没有。

Use the method Environment.isExternalStorageRemovable() to determine if it's a removable SD card or not.

编辑澄清:

考虑以下方法:

public enum ExternalStorageStatus { 
    READ_WRITE , READ_ONLY, NONE
}

public static ExternalStorageStatus checkExternalStorageStateAvailable(){
    String state = Environment.getExternalStorageState();

    if (Environment.MEDIA_MOUNTED.equals(state)) {
        return ExternalStorageStatus.READ_WRITE;
    } else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
        return ExternalStorageStatus.READ_ONLY;
    } else {
        return ExternalStorageStatus.NONE;
    }
}

方法 Environment.getExternalStorageState()返回存储的当前状态。如果没有真正的外部存储(即介质中 isExternalStorageRemoveable() ==假),那么这将返回内部存储的当前状态。如果 isExternalStorageRemoveable() == true,则getExternalStorageState()返回可移动SD卡的状态。

The method Environment.getExternalStorageState() returns the current state of your storage. If no REAL external storage (i.e. a medium in which isExternalStorageRemoveable() == false), then this returns the current state of your internal storage. If isExternalStorageRemoveable() == true, then getExternalStorageState() returns the state of your removable SD card.

实际外部存储的优先次序。

Actual external storage is prioritized.

这篇关于我们如何区分闪存和SD卡内存之间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆