我正面临一些奇怪的问题,关于记忆卡是否存在。我正在检查IsSDCARD在我的google nexus设备上是否恢复为真,但是当我尝试使用文件资源管理器从eclipse访问存储卡时,它在mnt文件夹中显示没有存储卡(存储卡前的阵列不存在)....Here是我的代码,请帮助
public static boolean isSDCardMounted() {
Boolean isSDPresent = android.os.Environment.getExternalStorageState()
.equals(android.os.Environment.MEDIA_MOUNTED);
Log.d("Tag", "SDCARD PRESENT....." + isSDPresent);
return isSDPresent;
}
if (!DownLoadFile.isSDCardMounted()) {
CommonFunctions.showAlerts(MainActivity.this,
"SD Card Not Available");
if (progressDialog.isShowing())
progressDialog.dismiss();
cancel(true);
}请帮帮忙……
发布于 2013-06-04 19:23:26
检查
public static boolean isExternalStorageRemovable ()在API级别9中添加
返回主“外部”存储设备是否可移除。如果返回true,则该设备例如是用户可以移除的SD卡。如果返回false,则存储内置于设备中,无法物理移除。
Environment.getExternalStorageDirectory()指的是设备制造商认为是“外部存储”的任何东西。在某些设备上,这是可移动介质,如SD卡。在一些设备上,这是设备上闪存的一部分,@CommonsWare在这里https://stackoverflow.com/a/5695129/786337已经回答了更多
发布于 2013-06-04 19:23:31
使用下面的代码行使用"Using the External Storage"中描述的Environment.getExternalStorageState()。
要获取外部存储上的可用空间,请使用StatFs
// do this only *after* you have checked external storage state:
File extdir = Environment.getExternalStorageDirectory();
File stats = new StatFs(extdir.getAbsolutePath());
int availableBytes = stats.getAvailableBlocks() * stats.getBlockSize();检查存储卡所有细节的代码在下面的http://sapienmobile.com/?p=204中提到
https://stackoverflow.com/questions/16916353
复制相似问题