我正在开发一个Android应用程序,在这个应用程序中,我从服务器获得图像url。现在我必须将图像url和图像文件保存在本地存储中,因为如果我想第一次检查我的内部存储中是否有相同的url,那么它将从我的本地存储中获得该图像文件,如果没有,它将首先将图像url引用和图像文件保存在我的内部存储中。
下面给出了我的代码。根据上述情况,我希望将图像url和图像文件保存在我的内部存储器中。
new DownloadImageTask((ImageView) view.findViewById(R.id.imageViewProfile))
.execute(imageURL);
private class DownloadImageTask extends AsyncTask<String, Void, Bitmap> {
ImageView bmImage;
public DownloadImageTask(ImageView bmImage) {
this.bmImage = bmImage;
}
protected Bitmap doInBackground(String... urls) {
String urldisplay = urls[0];
Bitmap mIcon11 = null;
try {
InputStream in = new java.net.URL(urldisplay).openStream();
mIcon11 = BitmapFactory.decodeStream(in);
} catch (Exception e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}
return mIcon11;
}
protected void onPostExecute(Bitmap result) {
bmImage.setImageBitmap(result);
}
}https://stackoverflow.com/questions/29889433
复制相似问题