1
我開發一個Android應用程序,我這樣做是爲了保存一個位圖到內部存儲器中的圖像:顯示存儲在內部存儲
protected void onPostExecute(Bitmap profilePicture)
{
FileOutputStream fOut = null;
try
{
fOut = openFileOutput(Constants.FB_PROFILE_IMAGE_FILE_NAME, Context.MODE_PRIVATE);
profilePicture.compress(Bitmap.CompressFormat.JPEG, 85, fOut);
fOut.flush();
}
catch (FileNotFoundException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
finally
{
try
{
fOut.close();
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
loadingDialog.dismiss();
}
我該怎麼做才能將它打開並顯示到ImageView
?
此代碼不起作用,因爲imgFile
不存在:
private void loadAndShowUserProfileImage()
{
File imgFile = new File(Constants.FB_PROFILE_IMAGE_FILE_NAME);
if(imgFile.exists())
{
Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
userImageProfile.setImageBitmap(myBitmap);
}
}
遺憾的錯字 – Blackbelt