Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
进程终止后android下载的文件丢失_Android_File_Process - Fatal编程技术网

进程终止后android下载的文件丢失

进程终止后android下载的文件丢失,android,file,process,Android,File,Process,我下载了一个jpeg文件并将其写入SD卡,但在进程被终止后,该文件丢失。为什么? 我写的文件如下: fileOut = new FileOutputStream(file); int length = 8192; byte[] buffer = new byte[length]; while (-1 != (length = in.read(buffer))) { fileOut.write(buffer, 0, length); } fileOut.flush(); fileOut.c

我下载了一个jpeg文件并将其写入SD卡,但在进程被终止后,该文件丢失。为什么?

我写的文件如下:

fileOut = new FileOutputStream(file);
int length = 8192;
byte[] buffer = new byte[length];
while (-1 != (length = in.read(buffer))) {
    fileOut.write(buffer, 0, length);
}
fileOut.flush();
fileOut.close();
这是代码出口:

System.exit(0);

首先,不要在Android上调用System.exit。第二,Android版本是什么?你是如何测试文件丢失的?android4.0,在adb shell中搜索文件,如下所示:busybox查找-名称文件名和如何关闭应用程序进程?不要!Android的一个基本原则是,除非系统需要它的资源,否则该进程将保留下来以供潜在的重用。作为开发人员,您通常不应该试图关闭流程。