我正在从一个SQL数据库的android设备上下载图片;除了打开Stream需要很长时间(即使没有下载图片),一切都运行良好。实际下载开始前大约需要5秒。这里是我的代码片段:URL.openStream非常慢
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..
行InputStream input = new BufferedInputStream(url.openStream());
给出了这个问题。任何想法如何加快速度?
您是否确定延迟发生在该声明中?我期望它发生在connect()调用中。 –