如何在检查存在的内部和外部存储 [英] how to check internal and external storage if exist

查看:143
本文介绍了如何在检查存在的内部和外部存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么知道是否有内部和外部存储在Android的务实?没有人怎么知道如何检查内部和外部存储

How do i know if there are internal and external storage in android pragmatically? does anyone how to know how to check both internal and external storage

在此先感谢

推荐答案

它已经在的 Android的文档

从文档拍摄的 code

boolean mExternalStorageAvailable = false;
boolean mExternalStorageWriteable = false;
String state = Environment.getExternalStorageState();

if (Environment.MEDIA_MOUNTED.equals(state)) {
    // We can read and write the media
    mExternalStorageAvailable = mExternalStorageWriteable = true;
} else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
    // We can only read the media
    mExternalStorageAvailable = true;
    mExternalStorageWriteable = false;
} else {
    // Something else is wrong. It may be one of many other states, but all we need
    //  to know is we can neither read nor write
    mExternalStorageAvailable = mExternalStorageWriteable = false;
}

这篇关于如何在检查存在的内部和外部存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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