Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.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_Image_File_Download - Fatal编程技术网

在android中卸载应用程序时如何防止删除应用程序文件

在android中卸载应用程序时如何防止删除应用程序文件,android,image,file,download,Android,Image,File,Download,下载文件的路径如下: DownloadManager mgr = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE); Uri downloadUri = Uri.parse(file_url); DownloadManager.Request request = new DownloadManager.Request(downloadUri); request.setAllowedNetworkTypes(

下载文件的路径如下:

DownloadManager mgr = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);

Uri downloadUri = Uri.parse(file_url);
DownloadManager.Request request = new DownloadManager.Request(downloadUri);

request.setAllowedNetworkTypes(
        DownloadManager.Request.NETWORK_WIFI | DownloadManager.Request.NETWORK_MOBILE)
        .setTitle("")
        .setDestinationInExternalPublicDir(Environment.DIRECTORY_PICTURES + "/MyApp", tsLong.toString() + ".jpg");
我发现一旦卸载应用程序,文件夹也会被删除,如何保存


非常感谢。

非常感谢您提供的信息,因为建议您停止使用下载管理器,还有什么其他选择?感谢使用您最喜爱的HTTP客户端API(OkHttp、Volley、
HttpUrlConnection
,等等),从您自己的前台
IntentService
new File(Environment.DIRECTORY_PICTURES + "/MyApp")