public static boolean deleteFile(String filePath) {
File file = new File(filePath);
if (file.isFile() && file.exists()) {
return file.delete();
}
return false;
}
AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.MyAlertDialogStyle);
builder.setMessage("您确定要删除该文件吗?");
builder.setCancelable(false);
builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (VoiceFileUtil.deleteFile(filePath) {
ToastUtils.showShort("删除成功");
} else {
ToastUtils.showShort("删除失败");
}
}
});
builder.setNeutralButton("取消", null);
builder.create().show();
<style name="MyAlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="colorAccent">@color/dialogColor</item>
</style>
因篇幅问题不能全部显示,请点此查看更多更全内容