判断手机有无外置sd卡


private boolean haveSdcard(){
StorageManager manager = (StorageManager) getSystemService(STORAGE_SERVICE);
StorageVolume[] mVolumes=manager.getVolumeList();

String ExternalStorage=null;

for(StorageVolume mVolume:mVolumes){
if(mVolume.isRemovable()){
ExternalStorage=mVolume.getPath();
}
}
if (ExternalStorage != null && testSd(ExternalStorage)) {
return true;
}else{
return false;
}
}


private boolean testSd(String interStorage) {
StatFs mStatFs = new StatFs(interStorage);
if (mStatFs.getBlockCount() > 0) {
return true;


} else {
return false;
}
}

发布了7 篇原创文章 · 获赞 4 · 访问量 1208

猜你喜欢

转载自blog.csdn.net/d_shaoshuai/article/details/51809647
今日推荐