I’m downloading a picture on a android device from a SQL database; Everything works well, except that opening the Stream takes very long time (even if there is no picture to download). It takes approx 5 sec’s before the actual download starts. Here is my code snippet:
URL url = new URL(sUrl[0]);
URLConnection connection = url.openConnection();
connection.connect();
int fileLength = connection.getContentLength();
//input = connection.getInputStream();
InputStream input = new BufferedInputStream(url.openStream());
File file = new File(
Environment
.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES),
"MyCameraApp" + "/testpic.jpg");
OutputStream output = new FileOutputStream(file);
byte data[] = new byte[1024];
//---blabla progressbar update etc..
The line InputStream input = new BufferedInputStream(url.openStream()); gives the problem. Any idea’s on how to speed things up?
I use this code to get a bitmap from a url. 🙂