我创建了一个在外部存储器中保存图像的方法。下一次当我调用这个方法时,它不能保存图片,因为使用该名称的图像已经保存。有没有办法覆盖已经保存的图像。
我创建了一个在外部存储器中保存图像的方法。下一次当我调用这个方法时,它不能保存图片,因为使用该名称的图像已经保存。有没有办法覆盖已经保存的图像。
检查是否已经存在同名图片。如果存在,则删除该图片,然后存储新图片。
/**
* We need to notify the MediaScanner when a new file is created.
* In this way all the gallery applications will be notified too.
*
* @param filepath
*/
private void updateMedia( String filepath ) {
Log.i( LOG_TAG, "updateMedia: " + filepath );
MediaScannerConnection.scanFile( getApplicationContext(), new String[] { filepath }, null, null );
}