我目前使用下面的代码下载,然后显示图像,而我只是希望有人能告诉我如何检查文件是否已经下载并只显示如果是这样,否则,然后下载并显示..请帮助。Android应用开发 - 下载一次,用于显示图像
void downloadFile(String fileUrl){
URL myFileUrl =null;
try {
myFileUrl= new URL(fileUrl);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
HttpURLConnection conn= (HttpURLConnection)myFileUrl.openConnection();
conn.setDoInput(true);
conn.connect();
InputStream is = conn.getInputStream();
Bitmap bmImg = BitmapFactory.decodeStream(is);
ImageView imView = (ImageView)findViewById(R.id.imview);
imView.setImageBitmap(bmImg);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}