I'm trying to save my images from ImageView to sd card and they are saving to sd card but they are not updating to gallery. Here is my code.
public void save(View v) {
bitmap = BitmapFactory.decodeResource(getResources(), backgrounds.get(currentPosition)) ;
File filepath = Environment.getExternalStorageDirectory();
File dir = new File(filepath.getAbsolutePath()
+ "/Folder/");
dir.mkdirs();
String Image = System.currentTimeMillis()+".Png";
File file = new File(dir, Image);
Toast.makeText(MainActivity.this, "Image Saved to SD Card",
Toast.LENGTH_SHORT).show();
try {
output = new FileOutputStream(file);
// Compress into png format image from 0% - 100%
bitmap.compress(Bitmap.CompressFormat.PNG, 100, output);
output.flush();
output.close();
}
catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}