Development of mobile database

xiaoxiao2021-03-06  118

1, javax.microedition.rms Content: · Class RecordStore · Interface RecordComparatorRecordEnumerationRecordFilterRecordListener · abnormal InvalidRecordIDExceptionRecordStoreExceptionRecordStoreFullExceptionRecordStoreNotFoundExceptionRecordStoreNotOpenException2, record warehouse (RMS) of open, close and delete · RecordStore.openRecordStore () open records storage, there are three ways 〓 first: Four Parameters! The first parameter: String, record the name of the warehouse! The second parameter: boolean, True means that the open recording storage does not exist, create a new one; false throws the RecordStorenoffoundException! The third parameter: authentication mode, read permissions; record.authmode_private (only this warehouse MIDlet Suite can access this warehouse); Record.AuthMode_any (any MIDlet on the device can read records)! Fourth parameter: boolean, write permission 〓 second: three parameters (specifically used to open a record warehouse belonging to other MIDLET Suite)! The first parameter: Record the name of the warehouse! Second parameter: MIDLET SUITE Supplier of supplier 〓 The third: two parameters! The first parameter: String, record the name of the warehouse! The second parameter: boolean, True means that the open recording storage does not exist, create a new one; false throws the RecordStorenoffoundException exception · RecordStore provided the setmode () method to change the record storage model and write rights (only Establishing this warehouse NIDLET to call this method) · RecordStore provides a list of the list of the MIDletStores (), which will make all the record warehousing in the MIDlet Suite existing in the MIDlet, and these names return to the number of strings. · When recording warehouse After completing, you must use the RecordStore class's closerecordStore () function to close the recording warehouse to release resources. If you do not need to store storage, use the RelecordStore class's deleteRecordStroe () method to delete the log warehouse; if the record warehouse is not closed , Then throwing RecordStoreException · GetLastModified () gets the recording storage storage timestamp · getNextRecordid () gets the value of the Next Record ID · GetNumRecords () gets the number of records recorded in the recording store · GetSize () gets the memory occupied by the current record storage Space · getSizeavailable () How much free space · getversion () gets the version number 3, the data is increased, modified, and deleted · int AddRecord (Byte [] Data, int offset, int NumBytes) Put the Byte array to the data storage. in,

And returned to its Record ID · Int getRecord (int Recordid, Byte [] Data, int offset) Removes the data of the specific Record ID. INT Recordid, Byte [] NewData, int offset, int numbertes sets data for specific IDs · Void deleteRecord (int Recordid) deletes data of a specific ID! The RecordStore class only provides services that are written to the BYTE array. When writing non-BYTE data types, it is more troublesome, as follows: ------------------------------------------------------ -------------------------------------------------- -------------------- Class: rmsutilimport javax.microedition.rms. *; Public class rmsutil {public rmsutil () {} // Open a record warehouse, not created public static RecordStore openRMSAnyway (String rmsname) {try {RecordStore rs = RecordStore.openRecordStore (rmsname, true); return rs;} catch (Exception e) {} return null;} // open an existing record repository, without no Create public static RecordStore openRMSExisted (String rmsname) {try {RecordStore rs = RecordStore.openRecordStore (rmsname, false); return rs;} catch (Exception e) {} return null;} // delete the existing record repository public static boolean DELETERMS (String RmsName) {IF (RMSName.Length ()> 32) Return False; try {recordstore.deleteRecordStore (RMSNAME);} catCH (Exception E) {Return False;} return true;} // Writing to record warehouse Character Public Static Int Writechar2RMS (RecordStore RS, Char Data) {byte [] TMP = New Byte [2]; TMP [0] = (Byte) (0xFF & (Data >> 8)); TMP [1] = (Byte (0xFF & (DATA >> 0)); try {return};} Catch (Exception E) {} Return -1;} // Read characters from record warehouse PUBLIC STATIC CHAR READCHAR4RMS (RecordStore RS, INT Recordid) {byte [] TMP = New Byte [2]; try {tmp = rs.getRecord (RecordID);} catch (Exception E) {} char result = (char) (TMP [0 ] & 0x00FF); Result = (CHAR) ((RESULT << 8) (CHAR) (TMP [1] & 0x00FF);

转载请注明原文地址:https://www.9cbs.com/read-98203.html

New Post(0)