📄 recordstore.html
字号:
<p> If this method is called by a MIDlet when the record store is already open by a MIDlet in the MIDlet suite, this method returns a reference to the same RecordStore object.</p><DD><DL>
<DT><B>Parameters:</B><DD><CODE>recordStoreName</CODE> - the MIDlet suite unique name for the record store, consisting of between one and 32 Unicode characters inclusive.<DD><CODE>createIfNecessary</CODE> - if true, the record store will be created if necessary<DD><CODE>authmode</CODE> - the mode under which to check or create access. Must be one of AUTHMODE_PRIVATE or AUTHMODE_ANY. This argument is ignored if the RecordStore exists.<DD><CODE>writable</CODE> - true if the RecordStore is to be writable by other MIDlet suites that are granted access. This argument is ignored if the RecordStore exists.<DT><B>Returns:</B><DD><code>RecordStore</code> object for the record store<DT><B>Throws:</B><DD><CODE><A HREF="../../../javax/microedition/rms/RecordStoreException.html">RecordStoreException</A></CODE> - if a record store-related exception occurred<DD><CODE><A HREF="../../../javax/microedition/rms/RecordStoreNotFoundException.html">RecordStoreNotFoundException</A></CODE> - if the record store could not be found<DD><CODE><A HREF="../../../javax/microedition/rms/RecordStoreFullException.html">RecordStoreFullException</A></CODE> - if the operation cannot be completed because the record store is full<DD><CODE><A HREF="../../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if authmode or recordStoreName is invalid<DT><B>Since: </B><DD>MIDP 2.0</DD>
</DL>
</DD>
</DL>
<HR>
<A NAME="openRecordStore(java.lang.String, java.lang.String, java.lang.String)"><!-- --></A><H3>
openRecordStore</H3>
<PRE>
public static <A HREF="../../../javax/microedition/rms/RecordStore.html">RecordStore</A> <B>openRecordStore</B>(<A HREF="../../../java/lang/String.html">String</A> recordStoreName, <A HREF="../../../java/lang/String.html">String</A> vendorName, <A HREF="../../../java/lang/String.html">String</A> suiteName) throws <A HREF="../../../javax/microedition/rms/RecordStoreException.html">RecordStoreException</A>, <A HREF="../../../javax/microedition/rms/RecordStoreNotFoundException.html">RecordStoreNotFoundException</A></PRE>
<DL>
<DD>Open a record store associated with the named MIDlet suite. The MIDlet suite is identified by MIDlet vendor and MIDlet name. Access is granted only if the authorization mode of the RecordStore allows access by the current MIDlet suite. Access is limited by the authorization mode set when the record store was created: <ul> <li><code>AUTHMODE_PRIVATE</code> - Succeeds only if vendorName and suiteName identify the current MIDlet suite; this case behaves identically to <code>openRecordStore(recordStoreName, createIfNecessary)</code>.</li> <li><code>AUTHMODE_ANY</code> - Always succeeds. Note that this makes your recordStore accessible by any other MIDlet on the device. This could have privacy and security issues depending on the data being shared. Please use carefully. Untrusted MIDlet suites are allowed to share data but this is not recommended. The authenticity of the origin of untrusted MIDlet suites cannot be verified so shared data may be used unscrupulously.</li> </ul> <p> If this method is called by a MIDlet when the record store is already open by a MIDlet in the MIDlet suite, this method returns a reference to the same RecordStore object.</p> <p> If a MIDlet calls this method to open a record store from its own suite, the behavior is identical to calling: <code><A HREF="../../../javax/microedition/rms/RecordStore.html#openRecordStore(java.lang.String, boolean)"><CODE>openRecordStore(recordStoreName, false)</CODE></A></code></p><DD><DL>
<DT><B>Parameters:</B><DD><CODE>recordStoreName</CODE> - the MIDlet suite unique name for the record store, consisting of between one and 32 Unicode characters inclusive.<DD><CODE>vendorName</CODE> - the vendor of the owning MIDlet suite<DD><CODE>suiteName</CODE> - the name of the MIDlet suite<DT><B>Returns:</B><DD><code>RecordStore</code> object for the record store<DT><B>Throws:</B><DD><CODE><A HREF="../../../javax/microedition/rms/RecordStoreException.html">RecordStoreException</A></CODE> - if a record store-related exception occurred<DD><CODE><A HREF="../../../javax/microedition/rms/RecordStoreNotFoundException.html">RecordStoreNotFoundException</A></CODE> - if the record store could not be found<DD><CODE><A HREF="../../../java/lang/SecurityException.html">SecurityException</A></CODE> - if this MIDlet Suite is not allowed to open the specified RecordStore.<DD><CODE><A HREF="../../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if recordStoreName is invalid<DT><B>Since: </B><DD>MIDP 2.0</DD>
</DL>
</DD>
</DL>
<HR>
<A NAME="setMode(int, boolean)"><!-- --></A><H3>
setMode</H3>
<PRE>
public void <B>setMode</B>(int authmode, boolean writable) throws <A HREF="../../../javax/microedition/rms/RecordStoreException.html">RecordStoreException</A></PRE>
<DL>
<DD>Changes the access mode for this RecordStore. The authorization mode choices are: <ul> <li><code>AUTHMODE_PRIVATE</code> - Only allows the MIDlet suite that created the RecordStore to access it. This case behaves identically to <code>openRecordStore(recordStoreName, createIfNecessary)</code>.</li> <li><code>AUTHMODE_ANY</code> - Allows any MIDlet to access the RecordStore. Note that this makes your recordStore accessible by any other MIDlet on the device. This could have privacy and security issues depending on the data being shared. Please use carefully.</li> </ul> <p>The owning MIDlet suite may always access the RecordStore and always has access to write and update the store. Only the owning MIDlet suite can change the mode of a RecordStore.</p><DD><DL>
<DT><B>Parameters:</B><DD><CODE>authmode</CODE> - the mode under which to check or create access. Must be one of AUTHMODE_PRIVATE or AUTHMODE_ANY.<DD><CODE>writable</CODE> - true if the RecordStore is to be writable by other MIDlet suites that are granted access<DT><B>Throws:</B><DD><CODE><A HREF="../../../javax/microedition/rms/RecordStoreException.html">RecordStoreException</A></CODE> - if a record store-related exception occurred<DD><CODE><A HREF="../../../java/lang/SecurityException.html">SecurityException</A></CODE> - if this MIDlet Suite is not allowed to change the mode of the RecordStore<DD><CODE><A HREF="../../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if authmode is invalid<DT><B>Since: </B><DD>MIDP 2.0</DD>
</DL>
</DD>
</DL>
<HR>
<A NAME="closeRecordStore()"><!-- --></A><H3>
closeRecordStore</H3>
<PRE>
public void <B>closeRecordStore</B>() throws <A HREF="../../../javax/microedition/rms/RecordStoreNotOpenException.html">RecordStoreNotOpenException</A>, <A HREF="../../../javax/microedition/rms/RecordStoreException.html">RecordStoreException</A></PRE>
<DL>
<DD>This method is called when the MIDlet requests to have the record store closed. Note that the record store will not actually be closed until closeRecordStore() is called as many times as openRecordStore() was called. In other words, the MIDlet needs to make a balanced number of close calls as open calls before the record store is closed. <p>When the record store is closed, all listeners are removed and all RecordEnumerations associated with it become invalid. If the MIDlet attempts to perform operations on the RecordStore object after it has been closed, the methods will throw a RecordStoreNotOpenException.<DD><DL>
<DT><B>Throws:</B><DD><CODE><A HREF="../../../javax/microedition/rms/RecordStoreNotOpenException.html">RecordStoreNotOpenException</A></CODE> - if the record store is not open<DD><CODE><A HREF="../../../javax/microedition/rms/RecordStoreException.html">RecordStoreException</A></CODE> - if a different record store-related exception occurred</DL>
</DD>
</DL>
<HR>
<A NAME="listRecordStores()"><!-- --></A><H3>
listRecordStores</H3>
<PRE>
public static <A HREF="../../../java/lang/String.html">String</A>[] <B>listRecordStores</B>()</PRE>
<DL>
<DD>Returns an array of the names of record stores owned by the MIDlet suite. Note that if the MIDlet suite does not have any record stores, this function will return null. The order of RecordStore names returned is implementation dependent.<DD><DL>
<DT><B>Returns:</B><DD>array of the names of record stores owned by the MIDlet suite. Note that if the MIDlet suite does not have any record stores, this function will return null.</DL>
</DD>
</DL>
<HR>
<A NAME="getName()"><!-- --></A><H3>
getName</H3>
<PRE>
public <A HREF="../../../java/lang/String.html">String</A> <B>getName</B>() throws <A HREF="../../../javax/microedition/rms/RecordStoreNotOpenException.html">RecordStoreNotOpenException</A></PRE>
<DL>
<DD>Returns the name of this RecordStore.<DD><DL>
<DT><B>Returns:</B><DD>the name of this RecordStore<DT><B>Throws:</B><DD><CODE><A HREF="../../../javax/microedition/rms/RecordStoreNotOpenException.html">RecordStoreNotOpenException</A></CODE> - if the record store is not open</DL>
</DD>
</DL>
<HR>
<A NAME="getVersion()"><!-- --></A><H3>
getVersion</H3>
<PRE>
public int <B>getVersion</B>() throws <A HREF="../../../javax/microedition/rms/RecordStoreNotOpenException.html">RecordStoreNotOpenException</A></PRE>
<DL>
<DD>Each time a record store is modified (by <code>addRecord</code>, <code>setRecord</code>, or <code>deleteRecord</code> methods) its <em>version</em> is incremented. This can be used by MIDlets to quickly tell if anything has been modified. The initial version number is implementation dependent. The increment is a positive integer greater than 0. The version number increases only when the RecordStore is updated. The increment value need not be constant and may vary with each update.<DD><DL>
<DT><B>Returns:</B><DD>the current record store version<DT><B>Throws:</B><DD><CODE><A HREF="../../../javax/microedition/rms/RecordStoreNotOpenException.html">RecordStoreNotOpenException</A></CODE> - if the record store is not open</DL>
</DD>
</DL>
<HR>
<A NAME="getNumRecords()"><!-- --></A><H3>
getNumRecords</H3>
<PRE>
public int <B>getNumRecords</B>() throws <A HREF="../../../javax/microedition/rms/RecordStoreNotOpenException.html">RecordStoreNotOpenException</A></PRE>
<DL>
<DD>Returns the number of records currently in the record store.<DD><DL>
<DT><B>Returns:</B><DD>the number of records currently in the record store<DT><B>Throws:</B><DD><CODE><A HREF="../../../javax/microedition/rms/RecordStoreNotOpenException.html">RecordStoreNotOpenException</A></CODE> - if the record store is not open</DL>
</DD>
</DL>
<HR>
<A NAME="getSize()"><!-- --></A><H3>
getSize</H3>
<PRE>
public int <B>getSize</B>() throws <A HREF="../../../javax/microedition/rms/RecordStoreNotOpenException.html">RecordStoreNotOpenException</A></PRE>
<DL>
<DD>Returns the amount of space, in bytes, that the record store occupies. The size returned includes any overhead associated with the implementation, such as the data structures used to hold the state of the record store, etc.<DD><DL>
<DT><B>Returns:</B><DD>the size of the record store in bytes<DT><B>Throws:</B><DD><CODE><A HREF="../../../javax/microedition/rms/RecordStoreNotOpenException.html">RecordStoreNotOpenException</A></CODE> - if the record store is not open</DL>
</DD>
</DL>
<HR>
<A NAME="getSizeAvailable()"><!-- --></A><H3>
getSizeAvailable</H3>
<PRE>
public int <B>getSizeAvailable</B>() throws <A HREF="../../../javax/microedition/rms/RecordStoreNotOpenException.html">RecordStoreNotOpenException</A></PRE>
<DL>
<DD>Returns the amount of additional room (in bytes) available for this record store to grow. Note that this is not necessarily the amount of extra MIDlet-level data which can be stored, as implementations may store additional data structures with each record to support integration with native applications, synchronization, etc.<DD><DL>
<DT><B>Returns:</B><DD>the amount of additional room (in bytes) available for this record store to grow<DT><B>Throws:</B><DD><CODE><A HREF="../../../javax/microedition/rms/RecordStoreNotOpenException.html">RecordStoreNotOpenException</A></CODE> - if the record store is not open</DL>
</DD>
</DL>
<HR>
<A NAME="getLastModified()"><!-- --></A><H3>
getLastModified</H3>
<PRE>
public long <B>getLastModified</B>() throws <A HREF="../../../javax/microedition/rms/RecordStoreNotOpenException.html">RecordStoreNotOpenException</A></PRE>
<DL>
<DD>Returns the last time the record store was modified, in the format used by System.currentTimeMillis().<DD><DL>
<DT><B>Returns:</B><DD>the last time the record store was modified, in the format used by System.currentTimeMillis()<DT><B>Throws:</B><DD><CODE><A HREF="../../../javax/microedition/rms/RecordStoreNotOpenException.html">RecordStoreNotOpenException</A></CODE> - if the record store is not open</DL>
</DD>
</DL>
<HR>
<A NAME="addRecordListener(javax.microedition.rms.RecordListener)"><!-- --></A><H3>
addRecordListener</H3>
<PRE>
public void <B>addRecordListener</B>(<A HREF="../../../javax/microedition/rms/RecordListener.html">RecordListener</A> listener)</PRE>
<DL>
<DD>Adds the specified RecordListener. If the specified listener is already registered, it will not be added a second time. When a record store is closed, all listeners are removed.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>listener</CODE> - the RecordChangedListener<DT><B>See Also: </B><DD><A HREF="../../../javax/microedition/rms/RecordStore.html#removeRecordListener(javax.microedition.rms.RecordListener)"><CODE>removeRecordListener(javax.microedition.rms.RecordListener)</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="removeRecordListener(javax.microedition.rms.RecordListener)"><!-- --></A><H3>
removeRecordListener</H3>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -