My app loads a database file, say myDatabase.db, into in-memory data structures, i.e., various Java class objects. The user does inserts, deletes and edits on the the in-memory structures. I'm trying to decide what is the best way to save these changes back to a disk file.
I can either (a) do the corresponding inserts, deletes, & updates at the same time as the internal data structures are changed, thus keeping myDatabase.db always in sync, (b) somehow stack up the changes and defer changes to myDatabase.db at the end of the session.
One advantage of (b) is it would allow a final "Do you want to save these changes?" before committing. Implementing (a) appears to be easier but I would like to offer the user the opportunity to abandon the changes.
Which brings me to the question: what's the best way to clone the database upon loading? If I can do that I can use (a) making changes to the clone, then use it to overwrite myDatabase.db if the user wishes.
TIA
Ed S
Aucun commentaire:
Enregistrer un commentaire