Usually the levels are stored on the hard disk. When loaded from there the levels can be played in JSoko. When new solutions have been found (for instance by the built-in solver of JSoko) these solutions are added to the level as long as JSoko stays open. When JSoko is closed all found solutions are lost.
One way to store new solutions is to save a level back to hard disk. This has disadvantages:
- every time a new solution has been found and JSoko is to be closed the levels have to be saved to hard disk
- there either is a new file on the hard disk for the saved levels every time they are saved OR
- the level files on the hard disk are overwritten with the new data. While overwriting the files JSoko can't assure that the file format isn't destroyed - just because the files may be created by another Sokoban program using a different format for storing the level data than JSoko.
To avoid these disadvantages there is a database in JSoko. It can be used to store a single level or a whole level collection consisting of several levels.
The data is stored in the file: /leveldata/leveldataDB.data (this path is relative to the folder JSoko has been unzipped to)
The stored levels can be loaded from the database again and been played. When a new solution is found and a level has been loaded from the database this solution is automatically saved in the database, too. Hence, there is no need to save the level when JSoko is closed.
Note: This automatic saving is only done when a level has been loaded from the database.
Importing levels to the database
To import a level to the database there are three menu items in the "Database" menu of JSoko:
Import level to database
Imports the currently loaded level to the database. If an identical level is already stored in the database (identical = same board) then JSoko asks whether the levels is to be stored as new level or just the solutions of the level are to be added to the already stored level in the database. The imported level is imported using the collection "Unassigned levels" which means this level isn't assigned to any collection, yet.
Import collection to database
Imports the currently loaded collection to the database. All levels are imported and assigned to the collections. If the collection has been loaded from the database JSoko asks whether it has to be imported as new collection. Note: JSoko doesn't checks for duplicate levels when importing a collection. Hence, if you import collections which share identical levels these levels are stored twice in the database after the import
Import collections of folder ...
Shows a folder chooser for choosing the folder to select collections from. The selected folder and all sub folders are searched for *.txt, *.sok and *.xsb files. All of these files can be selected to be imported to the database.
Using the database
The database can be opened through the "Database" menu of JSoko by choosing the menu item "Browse database".
The database GUI consists of four tabs: