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