重载ApplicationWorkbenchWindowAdvisor中的postWindowClose() 方法
@Override
public void postWindowClose() {
// TODO Auto-generated method stub
//super.postWindowClose();
boolean openConfirm = MessageDialog.openConfirm(null, Messages.ApplicationWorkbenchWindowAdvisor_title, Messages.ApplicationWorkbenchWindowAdvisor_content);
if(openConfirm)
{
Location instanceLocation = Platform.getInstanceLocation();
URL path = instanceLocation.getURL();
//关闭数据库连接
SQLiteDBHelper.getSQLiteInstace().Close();
File workspace= new File(path.getPath());//+File.separator+SQLiteDBHelper.DB_FILE_NAME
//删除程序运行的临时记录
deleteFile(workspace);
}
}
//删除文件夹及文件夹内容
public void deleteFile(File targetFile)
{
if(targetFile.isDirectory())
{
File[] list = targetFile.listFiles();
for (int i = 0; i < list.length; i++) {
deleteFile(list[i]);
}
//
targetFile.deleteOnExit();
}
else
targetFile.deleteOnExit();
}