android中对sd卡的 操作文件问题 创建目录 创建文件到指定目录

步骤

1

获取sd卡的路径

File root =Environment.getExternalStorageDirectory();

2

确定要写文件的路径

String path =root.getAbsolutePath()+"/test2"+"/test3";

3

再把路径转化为file

File file =new File(path);

4创建目录

file.mkdir();

5在上述指定的目录写指定的文件

File file1 = new File(file,"Test.png");

一定要注意   path 与file的区别,还有一定要先建目录,在写文件·······

posted @ 2014-09-26 12:12  jiefeiduan  阅读(468)  评论(0编辑  收藏  举报