我想从SD卡上的framelayout保存图像。到目前为止我工作得非常好,但它得到了两次保存。首先在路径上我希望它被保存,第二个在“\ DCIM \ camera \”中。如何防止图像,也保存在“\ DCIM \ camera \”中? 这是我的代码:
frame.setDrawingCacheEnabled(true);
Bitmap bm = frame.getDrawingCache();
try {
String path = Environment.getExternalStorageDirectory().toString();
File imgDirectory = new File("/sdcard/MyApp/");
imgDirectory.mkdirs();
OutputStream fOut = null;
File file = null;
String fileid = System.currentTimeMillis() + "";
file = new File(path, "/MyApp/" + fileid + ".png");
Toast.makeText(PaintActivity.this, "saved at: " + file.getAbsolutePath(), Toast.LENGTH_SHORT).show();
fOut = new FileOutputStream(file);
bm.compress(Bitmap.CompressFormat.PNG, 100, fOut);
fOut.flush();
fOut.close();
MediaStore.Images.Media.insertImage(getContentResolver(), file.getAbsolutePath(), file.getName(),
file.getName());
} catch (Exception e) {
e.printStackTrace();
}