File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath(), "/短视频");
if (!file.exists()) {
file.mkdirs();
}
File file1 = new File(file, "/ship.txt");
if (!file1.exists()) {
try {
file1.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
try {
FileOutputStream fos = new FileOutputStream(file1);
String info = "内容";
fos.write(info.getBytes());
fos.close();
Log.e("----", "保存成功");
} catch (Exception e) {
e.printStackTrace();
}
由于安卓10系统修改了文件存储方式,使用android:requestLegacyExternalStorage="true"
启用旧的存储方式可以解决