1
我有一個應用程序使用畫布功能,我想保存和檢索所有圖像(無論我保存)。問題保存和檢索android中的圖像?
發出
我可以保存和檢索單個圖像只
動態我保存圖像,(image001,image002 ......)
更新
try {
toDisk.compress(Bitmap.CompressFormat.JPEG, 100, new FileOutputStream(new File("/mnt/sdcard/image00"+saveimageid+".jpg")));
saveimageid++;
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
我從image001中檢索圖像。
File imgFile = new File("/mnt/sdcard/image001.jpg");
if(imgFile.exists()){
Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
ImageView myImage = (ImageView) findViewById(R.id.ImageView01);
myImage.setImageBitmap(myBitmap);
我已更新我的代碼,通過使用此代碼我的圖像未保存,我無法檢索 – Mercy 2012-02-24 11:36:09
爲什麼更新您的代碼?這不是如何工作。這使我的回答與問題無關。如果你更新你還應該保留原來的代碼。 你的問題是什麼?您的評論沒有描述問題。您應該有一個包含> 0個可供您使用的文件的數組。 – 2012-02-24 11:42:31
其實我的問題是我想隨機保存圖像,我想檢索圖像。通過使用此代碼我無法檢索圖像並正確保存圖像。kindly幫助我。我會更新我的原始代碼 – Mercy 2012-02-24 11:46:03