外部存储

  1. 判断sdk是否可用
 if ((Environment.MEDIA_MOUNTED).equals(Environment.getExternalStorageState())){
                            Toast.makeText(getApplicationContext(),"sdk可用" ,Toast.LENGTH_LONG).show();
                        }
  1. 获取外部存储路径 String path = Environment.getExternalStorageDirectory().getPath(); 已过时
    FileOutputStream fileOutputStream=new FileOutputStream(new File(path,“c.txt”));
  2. 权限 但是依然会权限拒绝的错误 据说安卓6.0以上需要动态添加权限

。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
获取sdk总大小 Environment.getExternalStorageDirectory().getTotalSpace()
获取sdk可用空间Environment.getExternalStorageDirectory().getUsableSpace()

发布了16 篇原创文章 · 获赞 0 · 访问量 842

猜你喜欢

转载自blog.csdn.net/weixin_45830683/article/details/103102610