Palm OS Databases (Cont.)
Using the Data Manager
Using the Data Manager
is similar to using a traditional file manager, except that the data is broken down into multiple records instead of being stored in one contiguous chunk.
- To create or delete a database, call DmCreateDatabase and DmDeleteDatabase.
- To open a database for reading or writing, you must first get the database ID.
Calling DmFindDatabase searches a particular memory card for a database by name and returns the local ID of the database header.
Alternatively, calling DmGetDatabase returns the database ID for each database on a card by index.
- After determining the database ID, you can open the database for read-only or read/write access.
When you open a database, the system locks down the database header and returns a reference to a database access structure.
Call DmDatabaseInfo, DmSetDatabaseInfo, and DmDatabaseSize to query or set information about a database, such as its name, size, creation and modification dates, attributes, type, and creator.
- Call the following functions when viewing or updating a database:
- DmGetRecord takes a record index as a parameter, marks the record busy, and returns a handle to the record.
If a record is already busy when
DmGetRecord
is called, an error is returned.
- DmQueryRecord is faster if the application only needs to view the record; it does not check or set the
busy
bit, so it is not necessary to call DmReleaseRecord
when finished viewing the record.
- DmReleaseRecord clears the
busy
bit, and updates the modification number of the database and marks the record dirty if the dirty
parameter is true.