イメージビューを特定のフォルダーのイメージに保存したいのですが、このコードを試してみましたが、うまくいきません
public void saveImage(View v){
View content = findViewById(R.id.iv_photo);
content.setDrawingCacheEnabled(true);
Bitmap bitmap = content.getDrawingCache();
//File file = new File("/DCIM/Camera/image.jpg");
File root = Environment.getExternalStorageDirectory();
File file = new File(root.getAbsolutePath() + "/DCIM/image.jpg");
try {
file.createNewFile();
FileOutputStream ostream = new FileOutputStream(file);
bitmap.compress(CompressFormat.JPEG, 100, ostream);
ostream.close();
}catch (Exception e){
e.printStackTrace();
}
}
関数を呼び出すためのこのコード
saveImage(getWindow().getDecorView().findViewById(android.R.id.content));