On some devices, the file is loaded in five seconds, on others (Samsung J5 - Android 5.1, Genymotion Google Nexus S - Android 4.1.1) about a minute. What can this happen? Internet is normal on smartphones. Code:
public static boolean loadFile(Context context, File outFile) { int count; AppLog.d("loadFile, start = " + DateFormat.getDateTimeInstance().format(new Date())); try { CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_ALL)); URL url = new URL(url); URLConnection connection = url.openConnection(); connection.setConnectTimeout(ServiceClient.TIME_OUT); connection.connect(); // download the file InputStream input = new BufferedInputStream(url.openStream(), 8192); OutputStream output = new FileOutputStream(outFile); byte data[] = new byte[BUFFER_LENGTH]; while ((count = input.read(data)) != -1) { output.write(data, 0, count); } output.flush(); output.close(); input.close(); AppLog.d("loadFile, finish = " + DateFormat.getDateTimeInstance().format(new Date())); return true; } catch (Exception e) { e.printStackTrace(); return false; } }
Long loading occurs directly in the line:
output.write(data, 0, count);