我的应用程序从图库中获取图像并复制到子文件夹。但是,复制的图像作为来自不同位置的原始图像的副本进入画廊。
如何预防?请帮我。
这是我保存到预定义文件夹的代码....
protected String saveBitmap(Bitmap bm, String path) throws Exception {
String tempFilePath="/sdcard/AuFridis/Events/Images/"+System.currentTimeMillis()+"myEventImg.jpg";
File tempFile = new File(path+"/"+System.currentTimeMillis()+"myEventImg.jpg");
// File tempFile = new File("/sdcard/Notes");
tempFile.createNewFile();
if (!tempFile.exists()) {
if (!tempFile.getParentFile().exists()) {
tempFile.getParentFile().mkdirs();
}
}
//tempFile.delete();
//tempFile.createNewFile();
int quality = 100;
FileOutputStream fileOutputStream = new FileOutputStream(tempFile);
BufferedOutputStream bos = new BufferedOutputStream(fileOutputStream);
bm.compress(CompressFormat.JPEG, quality, bos);
bos.flush();
bos.close();
//bm.recycle();
Log.i("On saveBitmap Function - retrieved file path", "---"+tempFilePath);
return tempFilePath;
}