80,337
社区成员
发帖
与我相关
我的任务
分享
public static int isSdPresent() {
Boolean sdcardpresent = android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED);
if(sdcardpresent){
StatFs stat = new StatFs(android.os.Environment.getExternalStorageDirectory().getPath());
long bytesAvailable = (long)stat.getBlockSize() *(long)stat.getBlockCount();
long megAvailable = bytesAvailable / 1048576;
if(megAvailable>0.5){
return 0;
}else{
return 2;
}
}else{
return 1;
}
}
File storageFile = android.os.Environment.getExternalStorageDirectory().getAbsoluteFile();
Debug.log(Tag, "getCurrentAllMountedStoreDisk:storageFile==" + storageFile, FlagDebug);
int count = 0;
try {
File CanonicalFile = storageFile.getCanonicalFile();
File external = CanonicalFile.getParentFile();
Debug.log(Tag, "getCurrentAllMountedStoreDisk:CanonicalFile,external==" + CanonicalFile+","+external, FlagDebug);
if (!external.getAbsolutePath().equals(File.separator)) {
File[] file = external.listFiles();
for (int i = 0; i < file.length; i++) {
File tmp = file[i];
if (tmp.canRead() && tmp.canWrite() && tmp.isDirectory() && !tmp.isHidden()) {
Debug.log(Tag, "getCurrentAllMountedStoreDisk:file:" + tmp.getAbsolutePath(), FlagDebug);
ret.add(tmp.getAbsolutePath());
count++;
}
}
}
} catch (IOException e) {
Debug.log(Tag, "initMount()", e, FlagDebug);
}