储存SD卡与没有SD卡

public class SDCardUtil {
public static String getDataStorageDir(){
boolean isSDExist=Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED);

File f=null;

//判断是否有SD卡

if(isSDExist){
f=new File(Environment.getExternalStorageDirectory()+"/mianzu_ao3");//新建外部存储卡目录

}else{

//没有SD卡

f=new File(MyApplication.getAppContext().getCacheDir()+"/mianzu_a03");//缓存目录

}
if(!f.exists()){
f.mkdir();

}

//返回存储目录

return f.getAbsolutePath();

}


}

你可能感兴趣的:(储存SD卡与没有SD卡)