我想從URL下載的圖像並保存到內部存儲 我有這樣的代碼,但如果我的手機不具備外部存儲的圖像不能被下載下載圖像到內部存儲器
Bitmap b=null;
URL url;
InputStream iStream=null;
File tmpFile;
try {
url = new URL(strURL);
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.connect();
iStream = urlConnection.getInputStream();
File cacheDirectory = context.getCacheDir();
tmpFile = new File(cacheDirectory.getPath() + "/news.png");
FileOutputStream fOutStream = new FileOutputStream(tmpFile);
b = BitmapFactory.decodeStream(iStream);
b.compress(Bitmap.CompressFormat.PNG,100, fOutStream);
fOutStream.flush();
fOutStream.close();
}
catch(Exception ee)
{
}
return b;
做你幫我從url下載映像到內部存儲內置存儲內存
我在這裏沒有看到問題。 –