Introduction to Java Mobile Phone/PDA programming 11-MIDP Database Design 1

Source: Internet
Author: User

JDBC is designed for desktop platforms or enterprise users and is not suitable for mobile communication devices.

MIDP provides a record-oriented database for permanent data storage, called the record management system"
Record Management System (RMS)

All classes related to the record management system are stored inJavax. microedition. RMSPackage, including:
One class:
Recordstore
Four interfaces:
Recorcomparator
Recordenumeration
Recordfilter
Recorlistener

Five exceptions:
Invalidrecordidexception
Recordstoreexception
Recordstorefullexception
Recordstorenotfoundexception
Recordstorenotopenexception

A common database management system stores tables ),
Stored in the record management systemRecord warehousing(Record store ).

Record full name of Warehouse(32 Unicode characters at most, case sensitive ):
MIDlet suite name + Supplier name + record warehouse name
On the actual device, the full name of a MIDlet suite is:
MIDlet suite name + Supplier name + version number
That is, MIDlet suite-name + MIDlet-vendor + MIDlet-version

If you think of a record warehouse as a table, this table has only two fields (column)
One isRecord ID, One isData

Recordstore classRepresents a unique record store. We useOpenrecordstore ()Enable record warehousing,
This is a design model for static factory methods. Instead of creating a recordstore object through new.

Openrecordstore ()Constructor
4 parameters:
Record warehouse name
Boolean value. True indicates that if the enabled record does not exist, a new data warehouse is created. If false does not exist, a recordstorenotfoundexecption exception is thrown.
Authentication mode. Accept: record. authmode_private -- only the MIDlet suite that creates the record warehouse can access this record warehouse,
Record. authmode_any -- any MIDlet on the device can be stored using read records.
Boolean value, whether other MIDlet on the device can write data to the record warehouse.
Other MIDlet reads the record warehouse: The third parameter determines the read permission, and the fourth parameter determines the write permission.

If the memory is not enough when it is enabled, a recordstorefullexception will be thrown.

3 parameters:
Record warehouse name
Supplier name of MIDlet suite
Authentication Mode: record. authmode_private -- create a record warehouse MIDlet and the current MIDlet that calls it must belong to the same MIDlet suite,
Otherwise, securityexception; record. authmode_any -- any MIDlet can call this method.

2 parameters:
Record warehouse name
Boolean value. True indicates that if the enabled record does not exist, a new data warehouse is created. If false does not exist, a recordstorenotfoundexecption exception is thrown.

Setmode ()Method To change the Authentication Mode and write permission of the MIDlet in other MIDlet suites.
Listrecordstores () obtains the name of all record storages in the MIDlet suite where the current MIDlet is located.

UseCloserecordstore ()Close record storage to release system resources,
All recordlistener is cleared and related recordenumeration.
If it is disabled, a recordstroenotopenexception is thrown.

Deleterecordstore () deletes record warehousing. If the record warehouse is in use, a recordstorenotfoundexception is thrown.

Record Warehouse Information:
Name: record the name of the warehouse
Timestamp-Long TYPE: Time of the last change (obtained by system. currenttimemills)
Version Number: the initial value is 0, and 1 is added for each change.
Next record ID: the initial value is 1. Add 1 to each new record.

Getlastmodified () Get the timestamp
Getname () gets the name of the recorded warehouse
Getnextrecordid () gets the value of next record ID
Getnumrecords () obtains the number of records recorded in the record store.
Getsize () obtains the space occupied by the record warehouse.
Getsizeavailable () more space left
Getversion ()

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.