嗨,我正在製作一個Android應用程序,允許用戶在屏幕上繪圖。我有一個按鈕,當按下時,我希望畫布作爲圖像保存到內部存儲器中。我曾嘗試以下代碼,但我不斷收到FileNotFoundException open failed: EACCES (permission denied)
:Android - 如何將畫布保存到內存中的圖像
String path = Environment.getDataDirectory().getAbsolutePath();
File file = new File(path+"image.png");
Bitmap bitmap = Bitmap.createBitmap(100,200,Bitmap.Config.ARGB_8888);
FileOutputStream ostream;
try {
ostream = new FileOutputStream(file);
bitmap.compress(CompressFormat.PNG, 100, ostream);
ostream.flush();
ostream.close();
} catch (IOException e) {
e.printStackTrace();
}
的類型的方法openFileOutput(字符串,整數)上下文不適用於參數(字符串) – Poensvah 2013-04-24 18:52:57
@Poensvah它是'openFileInput(String)',對於'openFileOutput(String,int)'你想選擇一個模式,它是一個int常數。 – StoneBird 2013-04-24 19:44:31