I was thinking of adding Runtime.getRuntime().addShutdownHook to the Data class contructor so that I can place a thread in there that will close the database file just before the program terminates.
Since there is no method that that says connectDatabase on the Interface that I was given, I assumed that there will be no need for a method that says closeDatabase(). So I will add some code to the Data class constructor to close the database instead of extending the interface I was provided with to add a method that closes the database.
(That's not an easy first name to write and pronounce )
I did exactly the same, although I added a start and stop method to my custom interface. Because of my approach (record cache) a nice cleanup and stop of the database is very important, so I added Runtime.getRuntime().addShutdownHook() to the constructor of the Data class. That gives the guarantee that the database is closed nicely and everything is written back to file.