【发布时间】:2015-09-24 09:52:48
【问题描述】:
我创建了一种将图像保存在外部存储中的方法。下次当我回忆起这种方法时,它无法保存图像,因为该名称图像已经保存。有没有办法覆盖已经保存的图像。
【问题讨论】:
-
请看我的回答。
标签: java android eclipse android-sdk-tools
我创建了一种将图像保存在外部存储中的方法。下次当我回忆起这种方法时,它无法保存图像,因为该名称图像已经保存。有没有办法覆盖已经保存的图像。
【问题讨论】:
标签: java android eclipse android-sdk-tools
检查是否已经存在同名的图像。然后删除图像(如果存在)。然后存储新图像。
【讨论】:
你可以试试这个方法——
/**
* 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 );
}
【讨论】: