1

I have been using the Swing Application Framework, and very pleased with its sessions state storage. I was wondering if it's possible to delete (clean up) the persisted states.

  • of All dialog forms. or
  • of specific dialog forms.

If not, has anyone found a clean way to achieve this (stored files aren't saved in the same location depending on the OS etc..).

Thanks

Marc
  • 351
  • 4
  • 13

2 Answers2

1

you can delete the corresponding file/s (forgot the exact details about the naming) via the LocalStorage, here's a code snippet I use (with bsaf, but didn't change much, afair)

/**
 * Deletes the session state by deleting the file. Useful during development
 * when restoring to old state is not always the desired behaviour.
 * Pending: this is incomplete, deletes the mainframe state only.
 */
protected void deleteSessionState() {
    ApplicationContext context = getContext();
    try {
        context.getLocalStorage().deleteFile("mainFrame.session.xml");
    } catch (...) {
    }
}
kleopatra
  • 51,061
  • 28
  • 99
  • 211
  • Thank you, that's what I needed. I will use a variant of what you coded, to delete them ALL. – Marc Apr 20 '11 at 12:28
0
        File directory = context.getLocalStorage().getDirectory();
        directory = directory.getCanonicalFile();
        Files.deleteDirectoryContents(directory);

Files is the google io lib.

Marc
  • 351
  • 4
  • 13