Hello all i am saving my imageviews Bitmap as jpeg/png format but they are not listing in my image gallery( android default gallery)
THis is my method:
public void save_Image() {
String path = Environment.getExternalStorageDirectory().toString()
+ "/ImageFrame";
Log.d("Files", "Path: " + path);
File f = new File(path);
File file[] = f.listFiles();
Log.d("Files", "Size: " + file.length);
for (int i = 0; i < file.length; i++) {
Log.d("Files", "FileName:" + file[i].getName());
}
// BitmapDrawable drawable = (BitmapDrawable) img_large.getDrawable();
// Bitmap bitmap = drawable.getBitmap();
RelativeLayout frm_l = (RelativeLayout) findViewById(R.id.frm_l);
frm_l.setDrawingCacheEnabled(true);
Bitmap bitmap = frm_l.getDrawingCache();
File image = new File(sdCardDirectory + "/ImageFrame/", "HDWallpaper "
+ file.length + ".png");
//File image = new File(sdCardDirectory + "/ImageFrame/", "HDWallpaper "
// + file.length + ".jpeg");
boolean success = false;
FileOutputStream outStream;
try {
outStream = new FileOutputStream(image);
bitmap.compress(Bitmap.CompressFormat.PNG, 100, outStream);
// bitmap.compress(Bitmap.CompressFormat.JPEG, 100, outStream);
/* 100 to keep full quality of the image */
outStream.flush();
outStream.close();
success = true;
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
if (success) {
System.out.println("this is path where stored.."
+ Environment.getExternalStorageDirectory()
.getAbsolutePath());
Toast.makeText(getApplicationContext(),
"Saved Successfully", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(getApplicationContext(),
"Error during image sending", Toast.LENGTH_LONG).show();
}
}
This method works properly for me and saves bitmap But it does not list in my image gellery what should i do to overcome this problem?