Ste*_*ldt 3 android android-sdcard
没有SD卡的三星galaxy S3,我正在使用此代码来检查存储状态.
使用此代码:
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;
}
Run Code Online (Sandbox Code Playgroud)
所以也许有人可以向我解释这款手机出于某种原因是否将其内存视为外部?或者是什么?
Moi*_*med 12
getExternalStorageDirectory并不总是返回SD卡.
谷歌文档说:
"不要在这里混淆"外部"这个词.这个目录可以更好地被认为是媒体/共享存储.它是一个文件系统,可以容纳相对大量的数据,并在所有应用程序之间共享(不强制执行)传统上,这是一张SD卡,但它也可以作为内置存储实现在与受保护的内部存储不同的设备中,并且可以作为文件系统安装在计算机上."
可能有"/ mnt/sdcard"指的是手机的内置存储空间.
最好从方法检查返回路径getExternalStorageDirectory是否是外部可移动存储.
您可以使用Environment.isExternalStorageRemovable()进行检查.
Android 始终将一个已安装的硬件内存(如果有可用)报告为外部存储。
该内存可以是:
一台设备甚至可以同时拥有这两种设备,但 Android 只会报告其中一种(主要是内部设备)。
获取安装内容的简单方法adb shell mount。
rootfs on / type rootfs (ro)
tmpfs on /dev type tmpfs (rw,nosuid,mode=755)
devpts on /dev/pts type devpts (rw,mode=600)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
tmpfs on /mnt/asec type tmpfs (rw,mode=755,gid=1000)
tmpfs on /mnt/obb type tmpfs (rw,mode=755,gid=1000)
/dev/block/mtdblock2 on /system type yaffs2 (ro)
/dev/block/mtdblock3 on /data type yaffs2 (rw,nosuid,nodev)
/dev/block/mtdblock1 on /cache type yaffs2 (rw,nosuid,nodev)
/dev/block/vold/179:1 on /mnt/sdcard type vfat (rw,dirsync,nosuid,nodev,noexec,uid=1000,gid=1015,fmask=0702,dmask=0702,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro)
/dev/block/vold/179:1 on /mnt/secure/asec type vfat (rw,dirsync,nosuid,nodev,noexec,uid=1000,gid=1015,fmask=0702,dmask=0702,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4578 次 |
| 最近记录: |