File file = getExternalFilesDir(null);
try {
if (!file.exists()) {
file.createNewFile();
}
FileOutputStream fos = new FileOutputStream(path, true);
String str = infoEdt.getText().toString();
fos.write(str.getBytes());
} catch (IOException e) {
e.printStackTrace();
}
break;
case R.id.read_btn:
try {
FileInputStream fis = new FileInputStream(path);
byte[] b = new byte[1024];
《Android学习笔记总结+最新移动架构视频+大厂安卓面试真题+项目实战源码讲义》无偿开源 徽信搜索公众号【编程进阶路】 int len = fis.read(b);
String str2 = new String(b, 0, len);
txt.setText(str2);
} catch (Exception e) {
e.printStackTrace();
}
break;
}
}
}
打印出来的具体位置如下所示(结合概述所讲内容可以知道这个目录我们可以在映射目录 sdcard 下面找到):