![]() |
![]() |
![]() |
![]() |
IMPORTANT: Expect the database header structure to change in the future. Use the API to work with database structures.
name field holds the name of the database. attributes field has flags for the database. version field holds an application-specific version number for that database. modificationNumber is incremented every time a record in the database is deleted, added, or modified. Thus applications can quickly determine if a shared database has been modified by another process. appInfoID is an optional field that an application can use to store application-specific information about the database. For example, it might be used to store user display preferences for a particular database. sortInfoID is another optional field an application can use for storing the local ID of a sort table for the database. type and creator fields are each 4 bytes and hold the database type and creator. The system uses these fields to distinguish application databases from data databases and to associate data databases with the appropriate application. numRecords field holds the number of record entries stored in the database header itself. If all the record entries cannot fit in the header, then nextRecordList has the local ID of a recordList that contains the next set of records. attribute field, shown in Figure 7.1, is 8 bits long and contains 4 flags and a 4-bit category number. The category number is used to place records into user-defined categories like "business" or "personal."
delete bit is set in the attributes flags, but its entry in the database header remains until the next synchronization with the PC. dirty bit is set whenever a record is updated.busy bit is set when an application currently has a record locked for reading or writing.secret bit is set for records that should not be displayed before the user password has been entered on the device.delete bit is set in the attributes. When the user archives a record, the deleted bit is also set but the chunk is not freed and the local ID is preserved. This way, the next time the user synchronizes with the desktop system, the desktop can quickly determine which records to delete (since their record entries are still around on the Palm OS device). In the case of archived records, the desktop can save the record data on the PC before it permanently removes the record entry and data from the Palm OS device. For deleted records, the PC just has to delete the same record from the PC before permanently removing the record entry from the Palm OS device.
DmReleaseRecord when finished viewing the record. busy bit, and updates the modification number of the database and marks the record dirty if the dirty parameter is true.DmRemoveRecord, DmDeleteRecord, and DmArchiveRecord.
DmDeleteRecord and DmArchiveRecord are useful for synchronizing information with a desktop PC. Since the unique ID of the deleted or archived record is still kept in the database header, the desktop PC can perform the necessary operations on its own copy of the database before permanently removing the record from the Palm OS database.
DmDetachRecord removes a record entry from the database header and returns the record handle. Given the handle of a new record, DmAttachRecord inserts or appends that new record to a database or replaces an existing record with the new record. DmMoveRecord is an optimized way to move a record from one index to another in the same database.
dmHdrAttrResDB bit in the attributes field.
IMPORTANT: Expect the resource database header structure to change in the future. Use the API to work with resource database structures.
name field holds the name of the resource database. attributes field has flags for the database and always has the dmHdrAttrResDB bit set. modificationNumber is incremented every time a resource in the database is deleted, added, or modified. Thus, applications can quickly determine if a shared resource database has been modified by another process.appInfoID and sortInfoID fields are not normally needed for a resource database but are included to match the structure of a regular database. An application may optionally use these fields for its own purposes. type and creator fields hold 4-byte signatures of the database type and creator as defined by the application that created the database.numResources field holds the number of resource info entries that are stored in the header itself. In most cases, this is the total number of resources. If all the resource info entries cannot fit in the header, however, then nextResourceList has the chunkID of a resourceList that contains the next set of resource info entries.resDB parameter. If set, a resource database is created and the dmHdrAttrResDB bit is set in the attributes field of the database header. Given a database header ID, an application can determine which type of database it is by calling DmDatabaseInfo and examining the dmHdrAttrResDB bit in the returned attributes field.
returns a handle to a resource, given the type and ID. This routine searches all open resource databases for a resource of the given type and ID, and returns a handle to it. The search starts with the most recently opened database. To search only the most recently opened resource database for a resource instead of all open resource databases, call DmGet1Resource.
should be called as soon as an application finishes reading or writing the resource data. To resize a resource, call DmResizeResource, which accepts a handle to a resource and reallocates the resource in another heap of the same card if necessary. It returns the handle of the resource, which might have been changed if the resource had to be moved to another heap to be resized.
DmOpenRef of the open resource database that the resource belongs to must also be specified. Call DmSearchResource to find a resource by type and ID or by pointer by searching in all open resource databases.
DmOpenRef of the topmost open resource database, call DmNextOpenResDatabase and pass nil as the current DmOpenRef. To find out the DmOpenRef of each successive database, call DmNextOpenResDatabase repeatedly with each successive DmOpenRef.
<stdio.h> interface. Any C book that explains the <stdio.h> interface should serve as a suitable introduction to the concepts underlying the Palm OS File Streaming API. This section provides only a brief overview of the most commonly used file streaming functions.
<stdio.h> equivalents, the fread and fwrite functions. The other <stdio.h> routines have obvious analogs in the File Streaming API as well.
theStream = FileOpen(cardId,"KillerAppDataFile",
'KILR', 'KILD', fileModeReadOnly,
&err); fileModeAnyTypeCreator selector as a flag in the openMode parameter to the FileOpen function.
FileRead(theStream, &buf, objSize, numObjs,
&err); fileOpDestructiveReadMode selector as the value of the op parameter to the FileControl function.
FileDmRead function can read data directly into a Database Manager chunk for immediate addition to a Palm OS database.
| File Streaming Function Summary | |
|---|---|
| Opening and Closing | |
|
FileOpen FileSeek | FileClose |
| Reading Files | |
|
FileRead FileRewind |
FileDmRead FileControl |
| Writing to Files | |
| FileWrite | FileTruncate |
| File Information | |
| FileEOF | FileTell |
| Deleting Files | |
| FileDelete | FileFlush |
| Error Handling | |
|
FileError FileClearerr |
FileGetLastError |
|   | ![]() |
![]() |
![]() |
![]() |
  |