如果拍摄了一些照片,然后以邮件的形式发送出去或者已经使用过了,不想在保留在自己的手机里了。那就使用下面的代码 成功删除这些照片吧~
/**
*
* @param context
* @param file
*/
public static void deletePictures(Context context,File file){
Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
Uri uri = Uri.fromFile(file);
intent.setData(uri);
context.sendBroadcast(intent);
file.delete();
}
方法中的file是存放照片的文件,这样就可以成功删除啦~