【发布时间】:2019-06-25 05:52:40
【问题描述】:
val 下载目录 = 文件( Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), getString(R.string.app_name) )
if (!downloadDir.isDirectory) { //Creates directory named by this file downloadDir.mkdirs() } val file = File(downloadDir, fileName) try { val ostream = FileOutputStream(file) ostream.write(imageByteArray) ostream.flush() ostream.close() }
【问题讨论】:
-
是通过 Exception 做的吗?您是否在清单中添加了权限?
-
我也在清单中添加了权限。
-
例外情况如何?
-
没有异常,文件创建但转换为0B
-
imageByteArray来自哪里?你检查过这个字节数组吗?里面有数据吗?