try {
String filePath = Environment.getExternalStorageDirectory()
+ "/myappdir/" + appName + ".apk";
File file = new File(filePath);
file.getParentFile().mkdirs();
file.createNewFile();
BufferedOutputStream objectOut = new BufferedOutputStream(
new FileOutputStream(file));
objectOut.write(appByteArray);
objectOut.close();
} catch (Exception e) {
e.printStackTrace();
}
在下载到sd卡中 最好不要直接存储在根目录,因为sd卡根目录数量是有限的,还要有权限啊
android.permission.WRITE_EXTERNAL_STORAGE
本文介绍了如何在Android设备上将应用程序下载并保存到SD卡的具体实现方式,包括创建文件路径、使用BufferedOutputStream写入文件等步骤,并提醒开发者注意避免直接存储在SD卡根目录及确保具备WRITE_EXTERNAL_STORAGE权限。

被折叠的 条评论
为什么被折叠?



