I used this code to rescan the gallery. BUt everytime I am saving it overrides the existing image on the gallery the only image that shows is the latest image that I saved :( What would I do. Please help :(
private boolean storeImage(Bitmap imageData, String filename) {
String iconsStoragePath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + "/" + "PixiePhotos" + "/";
File sdIconStorageDir = new File(iconsStoragePath);
sdIconStorageDir.mkdirs();
try {
String filePath = sdIconStorageDir.toString() + filename;
FileOutputStream fileOutputStream = new FileOutputStream(filePath);
BufferedOutputStream bos = new BufferedOutputStream(fileOutputStream);
imageData.compress(CompressFormat.JPEG, 100, bos);
bos.flush();
bos.close();
//MediaScannerConnection.scanFile(this, new String[] { sdIconStorageDir.getPath() }, new String[] { "image/jpeg" }, null);
File refreshFile = new File(filePath);
Intent scanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
scanIntent.setData(Uri.fromFile(refreshFile));
sendBroadcast(scanIntent);
} catch (FileNotFoundException e) {
Log.w("TAG", "Error saving image file: " + e.getMessage());
return false;
} catch (IOException e) {
Log.w("TAG", "Error saving image file: " + e.getMessage());
return false;
}
return true;
}