I am downloading large zip files using Android DownloadManager. I have listview that shows list of all zip files and user can tap item to start downloading. Only one item can be downloaded at a time. When new list item starts downloading while other download is in progress i remove previous download id from queue. Everything is working fine. But sometimes i am getting ERROR_FILE_ERROR on LG g2 device OS 5.0.2. Here is code:
Uri uri = Uri.parse(path);
DownloadManager.Request request = new DownloadManager.Request(uri);
request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI | DownloadManager.Request.NETWORK_MOBILE);
request.setAllowedOverRoaming(false);
request.setVisibleInDownloadsUi(false);
String localStorageBasePath = FileUtils.zipDirectory(context).getAbsolutePath() + File.separator + fileName;
Uri localStorageBasePathUri = Uri.fromFile(new File(localStorageBasePath));
request.setDestinationUri(localStorageBasePathUri);
Long downloadId = downloadManager.enqueue(request);
It is working fine on other devices including nexus 5, samsung s3, note2, huawei etc. When i start downloading a file it instantly stops/failed with reason DownloadManager.ERROR_FILE_ERROR. I have tried to remove/clean external storage directory, making sure that its not ERROR_INSUFFICIENT_SPACE error etc. but it didn't work. Any help?