これが私のコードです...場所に保存したい場所がわかりDrawable d
ますFile f
:
ImageView imgView = (ImageView)header.findViewById(R.id.imvCover);
File cacheDir = this.getCacheDir();
File f = new File(cacheDir, itemDict.get("Barcode") + ".jpg");
if (f.exists())
{
Bitmap bmp = BitmapFactory.decodeFile(f.getAbsolutePath());
imgView.setImageBitmap(bmp);
}
else
{
String url = (String)itemDict.get("imageURL");
InputStream is = null;
try {
is = (InputStream) new URL(url).getContent();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
Drawable d = Drawable.createFromStream(is, "src");
if (d != null)
{
imgView.setImageDrawable(d);
// TODO: save the drawable into the cache directory
}
else
{
imgView.setImageResource(R.drawable.cam);
}
}
Drawable を .jpg として保存するにはどうすればよいですか?