DroidDB Tip of the Month
DroidDB® Tip for March 2013
Preventing and Recovering From "database disk image is malformed" Errors
When a handheld connects to a desktop as a "portable device", the handheld device controls how desktop applications can access the files on the handheld. One thing the handheld dis-allows is direct modification of a file on the handheld by a desktop application. If a desktop application wants to modify a file on the handheld, it has to copy the file to the desktop, modify it, and then copy it back to the handheld.
It is possible that, while a desktop application is modifying its copy of a file, a handheld application modifies the original file. When the desktop application copies the file back to the handheld, the changes made by the handheld application can get lost.
Furthermore, when changes are made by a handheld application to a file, some of these changes may not be visible to desktop applications until the handheld is disconnected and then reconnected to the desktop.
All this can cause a handheld file to become "malformed". There are things you can do to prevent a file from becoming malformed. And, if your database gets malformed, there are ways to recover.
Preventing a Malformed Database
There are two basic rules to follow to prevent malformed databases:
- Always close DroidDB on the desktop before disconnecting the handheld.
- Don't run a DroidDB form on the handheld while the handheld is connected to the desktop (in other words: close DroidDB on the desktop (if it is open), disconnect the handheld from the desktop, run the form, close the form, and then reconnect the handheld to the desktop).
Recovering a Malformed Database
If a database becomes malformed, the data in the database is lost and it is not recoverable. You can, however, recreate the tables and indexes in the database. To do this:
- If DroidDB is open on the dektop, close it.
- Connect the handheld to the desktop if not already connected
- Remove the database file from the application folder. This is a file with the same name as the application and has a .DB extension. When in the desktop file explorer, they are usually described as a "Database file". Be careful to only remove the .DB file but not the .DDB files.
- Open DroidDB on the desktop and open the application. DroidDB will see that there is no database and it will create an empty one.
- For each form in the application, do a FILE | OPEN to open the form and then FILE | SAVE. The definition of the strucure of the tables is stored in the forms and this will cause DroidDB to recreate the table using this stored definition.