{"id":317,"date":"2007-10-17T00:00:00","date_gmt":"2007-10-17T00:00:00","guid":{"rendered":"http:\/\/www.strongd.net\/?p=317"},"modified":"2007-10-17T00:00:00","modified_gmt":"2007-10-17T00:00:00","slug":"J2ME : Sort Record Example","status":"publish","type":"post","link":"https:\/\/www.strongd.net\/?p=317","title":{"rendered":"J2ME : Sort Record Example"},"content":{"rendered":"<p><DIV><FONT face=\"Courier New\"><FONT color=#7f0055><STRONG>import&nbsp;<\/STRONG><\/FONT><FONT color=#000000>javax.microedition.rms.*;<\/FONT><BR><FONT color=#7f0055><B>import&nbsp;<\/B><\/FONT><FONT color=#000000>javax.microedition.midlet.*;<\/FONT><BR><FONT color=#7f0055><B>import&nbsp;<\/B><\/FONT><FONT color=#000000>javax.microedition.lcdui.*;<\/FONT><BR><FONT color=#7f0055><B>import&nbsp;<\/B><\/FONT><FONT color=#000000>java.io.*;<\/FONT><BR><FONT color=#ffffff><\/FONT><BR><FONT color=#7f0055><B>public&nbsp;class&nbsp;<\/B><\/FONT><FONT color=#000000>SortExample&nbsp;<\/FONT><FONT color=#7f0055><B>extends&nbsp;<\/B><\/FONT><FONT color=#000000>MIDlet&nbsp;<\/FONT><FONT color=#7f0055><B>implements&nbsp;<\/B><\/FONT><FONT color=#000000>CommandListener<\/FONT><BR><FONT color=#000000>{<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>private&nbsp;<\/B><\/FONT><FONT color=#000000>Display&nbsp;display;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>private&nbsp;<\/B><\/FONT><FONT color=#000000>Alert&nbsp;alert;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>private&nbsp;<\/B><\/FONT><FONT color=#000000>Form&nbsp;<\/FONT><FONT color=#7f0055><B>form<\/B><\/FONT><FONT color=#000000>;&nbsp;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>private&nbsp;<\/B><\/FONT><FONT color=#000000>Command&nbsp;exit;&nbsp;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>private&nbsp;<\/B><\/FONT><FONT color=#000000>Command&nbsp;start;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>private&nbsp;<\/B><\/FONT><FONT color=#000000>RecordStore&nbsp;recordstore&nbsp;=&nbsp;<\/FONT><FONT color=#7f0055><B>null<\/B><\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>private&nbsp;<\/B><\/FONT><FONT color=#000000>RecordEnumeration&nbsp;recordEnumeration&nbsp;=&nbsp;<\/FONT><FONT color=#7f0055><B>null<\/B><\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>private&nbsp;<\/B><\/FONT><FONT color=#000000>Comparator&nbsp;comparator&nbsp;=&nbsp;<\/FONT><FONT color=#7f0055><B>null<\/B><\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>public&nbsp;<\/B><\/FONT><FONT color=#000000>SortExample&nbsp;<\/FONT><FONT color=#000000>()<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#000000>{<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>display&nbsp;=&nbsp;Display.getDisplay<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#7f0055><B>this<\/B><\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>exit&nbsp;=&nbsp;<\/FONT><FONT color=#7f0055><B>new&nbsp;<\/B><\/FONT><FONT color=#000000>Command<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#2a00ff>&#8220;Exit&#8221;<\/FONT><FONT color=#000000>,&nbsp;Command.SCREEN,&nbsp;<\/FONT><FONT color=#990000>1<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>start&nbsp;=&nbsp;<\/FONT><FONT color=#7f0055><B>new&nbsp;<\/B><\/FONT><FONT color=#000000>Command<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#2a00ff>&#8220;Start&#8221;<\/FONT><FONT color=#000000>,&nbsp;Command.SCREEN,&nbsp;<\/FONT><FONT color=#990000>1<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>form&nbsp;<\/B><\/FONT><FONT color=#000000>=&nbsp;<\/FONT><FONT color=#7f0055><B>new&nbsp;<\/B><\/FONT><FONT color=#000000>Form<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#2a00ff>&#8220;Mixed&nbsp;RecordEnumeration&#8221;<\/FONT><FONT color=#000000>,&nbsp;<\/FONT><FONT color=#7f0055><B>null<\/B><\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>form<\/B><\/FONT><FONT color=#000000>.addCommand<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>exit<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>form<\/B><\/FONT><FONT color=#000000>.addCommand<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>start<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>form<\/B><\/FONT><FONT color=#000000>.setCommandListener<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#7f0055><B>this<\/B><\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#000000>}<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>public&nbsp;<\/B><\/FONT><FONT color=#7f0055><B>void&nbsp;<\/B><\/FONT><FONT color=#000000>startApp<\/FONT><FONT color=#000000>()<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#000000>{<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>display.setCurrent<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#7f0055><B>form<\/B><\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#000000>}<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>public&nbsp;<\/B><\/FONT><FONT color=#7f0055><B>void&nbsp;<\/B><\/FONT><FONT color=#000000>pauseApp<\/FONT><FONT color=#000000>()<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#000000>{<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#000000>}<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>public&nbsp;<\/B><\/FONT><FONT color=#7f0055><B>void&nbsp;<\/B><\/FONT><FONT color=#000000>destroyApp<\/FONT><FONT color=#000000>(&nbsp;<\/FONT><FONT color=#7f0055><B>boolean&nbsp;<\/B><\/FONT><FONT color=#000000>unconditional&nbsp;<\/FONT><FONT color=#000000>)<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#000000>{<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#000000>}<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>public&nbsp;<\/B><\/FONT><FONT color=#7f0055><B>void&nbsp;<\/B><\/FONT><FONT color=#000000>commandAction<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>Command&nbsp;command,&nbsp;Displayable&nbsp;displayable<\/FONT><FONT color=#000000>)<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#000000>{<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>if&nbsp;<\/B><\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>command&nbsp;==&nbsp;exit<\/FONT><FONT color=#000000>)<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>{<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>destroyApp<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#7f0055><B>true<\/B><\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>notifyDestroyed<\/FONT><FONT color=#000000>()<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>}<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>else&nbsp;if&nbsp;<\/B><\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>command&nbsp;==&nbsp;start<\/FONT><FONT color=#000000>)<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>{<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>try<\/B><\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>{<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>recordstore&nbsp;=&nbsp;RecordStore.openRecordStore<\/FONT><FONT color=#000000>(<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#2a00ff>&#8220;myRecordStore&#8221;<\/FONT><FONT color=#000000>,&nbsp;<\/FONT><FONT color=#7f0055><B>true&nbsp;<\/B><\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>}<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>catch&nbsp;<\/B><\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>Exception&nbsp;error<\/FONT><FONT color=#000000>)<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>{<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>alert&nbsp;=&nbsp;<\/FONT><FONT color=#7f0055><B>new&nbsp;<\/B><\/FONT><FONT color=#000000>Alert<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#2a00ff>&#8220;Error&nbsp;Creating&#8221;<\/FONT><FONT color=#000000>,&nbsp;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>error.toString<\/FONT><FONT color=#000000>()<\/FONT><FONT color=#000000>,&nbsp;null,&nbsp;AlertType.WARNING<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;&nbsp;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>alert.setTimeout<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>Alert.FOREVER<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;&nbsp;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>display.setCurrent<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>alert<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>}<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>try<\/B><\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>{<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>String&nbsp;outputData<\/FONT><FONT color=#000000>[]&nbsp;<\/FONT><FONT color=#000000>=&nbsp;<\/FONT><FONT color=#000000>{<\/FONT><FONT color=#2a00ff>&#8220;Mary&#8221;<\/FONT><FONT color=#000000>,&nbsp;<\/FONT><FONT color=#2a00ff>&#8220;Bob&#8221;<\/FONT><FONT color=#000000>,&nbsp;<\/FONT><FONT color=#2a00ff>&#8220;Adam&#8221;<\/FONT><FONT color=#000000>}<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>for&nbsp;<\/B><\/FONT><FONT color=#000000>(<\/FONT><FONT color=#7f0055><B>int&nbsp;<\/B><\/FONT><FONT color=#000000>x&nbsp;=&nbsp;<\/FONT><FONT color=#990000>0<\/FONT><FONT color=#000000>;&nbsp;x&nbsp;&lt;&nbsp;<\/FONT><FONT color=#990000>3<\/FONT><FONT color=#000000>;&nbsp;x++<\/FONT><FONT color=#000000>)<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>{<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>byte<\/B><\/FONT><FONT color=#000000>[]&nbsp;<\/FONT><FONT color=#000000>byteOutputData&nbsp;=&nbsp;outputData<\/FONT><FONT color=#000000>[<\/FONT><FONT color=#000000>x<\/FONT><FONT color=#000000>]<\/FONT><FONT color=#000000>.getBytes<\/FONT><FONT color=#000000>()<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>recordstore.addRecord<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>byteOutputData,&nbsp;<\/FONT><FONT color=#990000>0<\/FONT><FONT color=#000000>,&nbsp;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>byteOutputData.length<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>}<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>}<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>catch&nbsp;<\/B><\/FONT><FONT color=#000000>(&nbsp;<\/FONT><FONT color=#000000>Exception&nbsp;error<\/FONT><FONT color=#000000>)<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>{<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>alert&nbsp;=&nbsp;<\/FONT><FONT color=#7f0055><B>new&nbsp;<\/B><\/FONT><FONT color=#000000>Alert<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#2a00ff>&#8220;Error&nbsp;Writing&#8221;<\/FONT><FONT color=#000000>,&nbsp;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>error.toString<\/FONT><FONT color=#000000>()<\/FONT><FONT color=#000000>,&nbsp;null,&nbsp;AlertType.WARNING<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;&nbsp;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>alert.setTimeout<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>Alert.FOREVER<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;&nbsp;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>display.setCurrent<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>alert<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>}<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>try<\/B><\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>{<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>StringBuffer&nbsp;buffer&nbsp;=&nbsp;<\/FONT><FONT color=#7f0055><B>new&nbsp;<\/B><\/FONT><FONT color=#000000>StringBuffer<\/FONT><FONT color=#000000>()<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>Comparator&nbsp;comparator&nbsp;=&nbsp;<\/FONT><FONT color=#7f0055><B>new&nbsp;<\/B><\/FONT><FONT color=#000000>Comparator<\/FONT><FONT color=#000000>()<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>recordEnumeration&nbsp;=&nbsp;recordstore.enumerateRecords<\/FONT><FONT color=#000000>(<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>null,&nbsp;comparator,&nbsp;<\/FONT><FONT color=#7f0055><B>false<\/B><\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>while&nbsp;<\/B><\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>recordEnumeration.hasNextElement<\/FONT><FONT color=#000000>())<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>{<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>buffer.append<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#7f0055><B>new&nbsp;<\/B><\/FONT><FONT color=#000000>String<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>recordEnumeration.nextRecord<\/FONT><FONT color=#000000>()))<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>buffer.append<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#2a00ff>&#8220;\\n&#8221;<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>}<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>alert&nbsp;=&nbsp;<\/FONT><FONT color=#7f0055><B>new&nbsp;<\/B><\/FONT><FONT color=#000000>Alert<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#2a00ff>&#8220;Reading&#8221;<\/FONT><FONT color=#000000>,&nbsp;buffer.toString<\/FONT><FONT color=#000000>()&nbsp;<\/FONT><FONT color=#000000>,&nbsp;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>null,&nbsp;AlertType.WARNING<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;&nbsp;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>alert.setTimeout<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>Alert.FOREVER<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;&nbsp;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>display.setCurrent<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>alert<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>}<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>catch&nbsp;<\/B><\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>Exception&nbsp;error<\/FONT><FONT color=#000000>)<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>{<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>alert&nbsp;=&nbsp;<\/FONT><FONT color=#7f0055><B>new&nbsp;<\/B><\/FONT><FONT color=#000000>Alert<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#2a00ff>&#8220;Error&nbsp;Reading&#8221;<\/FONT><FONT color=#000000>,&nbsp;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>error.toString<\/FONT><FONT color=#000000>()<\/FONT><FONT color=#000000>,&nbsp;null,&nbsp;AlertType.WARNING<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;&nbsp;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>alert.setTimeout<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>Alert.FOREVER<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;&nbsp;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>display.setCurrent<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>alert<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>}<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>try<\/B><\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>{<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>recordstore.closeRecordStore<\/FONT><FONT color=#000000>()<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>}<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>catch&nbsp;<\/B><\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>Exception&nbsp;error<\/FONT><FONT color=#000000>)<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>{<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>alert&nbsp;=&nbsp;<\/FONT><FONT color=#7f0055><B>new&nbsp;<\/B><\/FONT><FONT color=#000000>Alert<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#2a00ff>&#8220;Error&nbsp;Closing&#8221;<\/FONT><FONT color=#000000>,&nbsp;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>error.toString<\/FONT><FONT color=#000000>()<\/FONT><FONT color=#000000>,&nbsp;null,&nbsp;AlertType.WARNING<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;&nbsp;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>alert.setTimeout<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>Alert.FOREVER<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;&nbsp;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>display.setCurrent<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>alert<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>}<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>if&nbsp;<\/B><\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>RecordStore.listRecordStores<\/FONT><FONT color=#000000>()&nbsp;<\/FONT><FONT color=#000000>!=&nbsp;<\/FONT><FONT color=#7f0055><B>null<\/B><\/FONT><FONT color=#000000>)<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>{<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>try<\/B><\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>{<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>RecordStore.deleteRecordStore<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#2a00ff>&#8220;myRecordStore&#8221;<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>recordEnumeration.destroy<\/FONT><FONT color=#000000>()<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>}<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>catch&nbsp;<\/B><\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>Exception&nbsp;error<\/FONT><FONT color=#000000>)<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>{<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>alert&nbsp;=&nbsp;<\/FONT><FONT color=#7f0055><B>new&nbsp;<\/B><\/FONT><FONT color=#000000>Alert<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#2a00ff>&#8220;Error&nbsp;Removing&#8221;<\/FONT><FONT color=#000000>,&nbsp;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>error.toString<\/FONT><FONT color=#000000>()<\/FONT><FONT color=#000000>,&nbsp;null,&nbsp;AlertType.WARNING<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;&nbsp;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>alert.setTimeout<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>Alert.FOREVER<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;&nbsp;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>display.setCurrent<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>alert<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>}<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>}<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#000000>}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><BR><FONT color=#000000>}<\/FONT><BR><FONT color=#7f0055><B>class&nbsp;<\/B><\/FONT><FONT color=#000000>Comparator&nbsp;<\/FONT><FONT color=#7f0055><B>implements&nbsp;<\/B><\/FONT><FONT color=#000000>RecordComparator<\/FONT><BR><FONT color=#000000>{<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>public&nbsp;<\/B><\/FONT><FONT color=#7f0055><B>int&nbsp;<\/B><\/FONT><FONT color=#000000>compare<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#7f0055><B>byte<\/B><\/FONT><FONT color=#000000>[]&nbsp;<\/FONT><FONT color=#000000>record1,&nbsp;<\/FONT><FONT color=#7f0055><B>byte<\/B><\/FONT><FONT color=#000000>[]&nbsp;<\/FONT><FONT color=#000000>record2<\/FONT><FONT color=#000000>)<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#000000>{<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>String&nbsp;string1&nbsp;=&nbsp;<\/FONT><FONT color=#7f0055><B>new&nbsp;<\/B><\/FONT><FONT color=#000000>String<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>record1<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>,&nbsp;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#000000>string2=&nbsp;<\/FONT><FONT color=#7f0055><B>new&nbsp;<\/B><\/FONT><FONT color=#000000>String<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>record2<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>int&nbsp;<\/B><\/FONT><FONT color=#000000>comparison&nbsp;=&nbsp;string1.compareTo<\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>string2<\/FONT><FONT color=#000000>)<\/FONT><FONT color=#000000>;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>if&nbsp;<\/B><\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>comparison&nbsp;==&nbsp;<\/FONT><FONT color=#990000>0<\/FONT><FONT color=#000000>)<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>return&nbsp;<\/B><\/FONT><FONT color=#000000>RecordComparator.EQUIVALENT;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>else&nbsp;if&nbsp;<\/B><\/FONT><FONT color=#000000>(<\/FONT><FONT color=#000000>comparison&nbsp;&lt;&nbsp;<\/FONT><FONT color=#990000>0<\/FONT><FONT color=#000000>)<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>return&nbsp;<\/B><\/FONT><FONT color=#000000>RecordComparator.PRECEDES;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>else<\/B><\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#7f0055><B>return&nbsp;<\/B><\/FONT><FONT color=#000000>RecordComparator.FOLLOWS;<\/FONT><BR><FONT color=#ffffff>&nbsp;&nbsp;<\/FONT><FONT color=#000000>}<\/FONT><BR><FONT color=#000000>}<\/FONT><\/FONT><\/DIV><\/p>\n","protected":false},"excerpt":{"rendered":"<p>import&nbsp;javax.microedition.rms.*;import&nbsp;javax.microedition.midlet.*;import&nbsp;javax.microedition.lcdui.*;import&nbsp;java.io.*;public&nbsp;class&nbsp;SortExample&nbsp;extends&nbsp;MIDlet&nbsp;implements&nbsp;CommandListener{&nbsp;&nbsp;private&nbsp;Display&nbsp;display;&nbsp;&nbsp;private&nbsp;Alert&nbsp;alert;&nbsp;&nbsp;private&nbsp;Form&nbsp;form;&nbsp;&nbsp;&nbsp;private&nbsp;Command&nbsp;exit;&nbsp;&nbsp;&nbsp;private&nbsp;Command&nbsp;start;&nbsp;&nbsp;private&nbsp;RecordStore&nbsp;recordstore&nbsp;=&nbsp;null;&nbsp;&nbsp;private&nbsp;RecordEnumeration&nbsp;recordEnumeration&nbsp;=&nbsp;null;&nbsp;&nbsp;private&nbsp;Comparator&nbsp;comparator&nbsp;=&nbsp;null;&nbsp;&nbsp;public&nbsp;SortExample&nbsp;()&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;display&nbsp;=&nbsp;Display.getDisplay(this);&nbsp;&nbsp;&nbsp;&nbsp;exit&nbsp;=&nbsp;new&nbsp;Command(&#8220;Exit&#8221;,&nbsp;Command.SCREEN,&nbsp;1);&nbsp;&nbsp;&nbsp;&nbsp;start&nbsp;=&nbsp;new&nbsp;Command(&#8220;Start&#8221;,&nbsp;Command.SCREEN,&nbsp;1);&nbsp;&nbsp;&nbsp;&nbsp;form&nbsp;=&nbsp;new&nbsp;Form(&#8220;Mixed&nbsp;RecordEnumeration&#8221;,&nbsp;null);&nbsp;&nbsp;&nbsp;&nbsp;form.addCommand(exit);&nbsp;&nbsp;&nbsp;&nbsp;form.addCommand(start);&nbsp;&nbsp;&nbsp;&nbsp;form.setCommandListener(this);&nbsp;&nbsp;}&nbsp;&nbsp;public&nbsp;void&nbsp;startApp()&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;display.setCurrent(form);&nbsp;&nbsp;}&nbsp;&nbsp;public&nbsp;void&nbsp;pauseApp()&nbsp;&nbsp;{&nbsp;&nbsp;}&nbsp;&nbsp;public&nbsp;void&nbsp;destroyApp(&nbsp;boolean&nbsp;unconditional&nbsp;)&nbsp;&nbsp;{&nbsp;&nbsp;}&nbsp;&nbsp;public&nbsp;void&nbsp;commandAction(Command&nbsp;command,&nbsp;Displayable&nbsp;displayable)&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(command&nbsp;==&nbsp;exit)&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;destroyApp(true);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;notifyDestroyed();&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;if&nbsp;(command&nbsp;==&nbsp;start)&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;recordstore&nbsp;=&nbsp;RecordStore.openRecordStore(&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8220;myRecordStore&#8221;,&nbsp;true&nbsp;);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;catch&nbsp;(Exception&nbsp;error)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alert&nbsp;=&nbsp;new&nbsp;Alert(&#8220;Error&nbsp;Creating&#8221;,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;error.toString(),&nbsp;null,&nbsp;AlertType.WARNING);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alert.setTimeout(Alert.FOREVER);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;display.setCurrent(alert);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String&nbsp;outputData[]&nbsp;=&nbsp;{&#8220;Mary&#8221;,&nbsp;&#8220;Bob&#8221;,&nbsp;&#8220;Adam&#8221;};&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;(int&nbsp;x&nbsp;=&nbsp;0;&nbsp;x&nbsp;&lt;&nbsp;3;&nbsp;x++)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;byte[]&nbsp;byteOutputData&nbsp;=&nbsp;outputData[x].getBytes();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;recordstore.addRecord(byteOutputData,&nbsp;0,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;byteOutputData.length);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;catch&nbsp;(&nbsp;Exception&nbsp;error)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alert&nbsp;=&nbsp;new&nbsp;Alert(&#8220;Error&nbsp;Writing&#8221;,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;error.toString(),&nbsp;null,&nbsp;AlertType.WARNING);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alert.setTimeout(Alert.FOREVER);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;display.setCurrent(alert);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;StringBuffer&nbsp;buffer&nbsp;=&nbsp;new&nbsp;StringBuffer();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Comparator&nbsp;comparator&nbsp;=&nbsp;new&nbsp;Comparator();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;recordEnumeration&nbsp;=&nbsp;recordstore.enumerateRecords(&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;null,&nbsp;comparator,&nbsp;false);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while&nbsp;(recordEnumeration.hasNextElement())&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;buffer.append(new&nbsp;String(recordEnumeration.nextRecord()));&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;buffer.append(&#8220;\\n&#8221;);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alert&nbsp;=&nbsp;new&nbsp;Alert(&#8220;Reading&#8221;,&nbsp;buffer.toString()&nbsp;,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;null,&nbsp;AlertType.WARNING);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alert.setTimeout(Alert.FOREVER);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;display.setCurrent(alert);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;catch&nbsp;(Exception&nbsp;error)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alert&nbsp;=&nbsp;new&nbsp;Alert(&#8220;Error&nbsp;Reading&#8221;,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;error.toString(),&nbsp;null,&nbsp;AlertType.WARNING);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alert.setTimeout(Alert.FOREVER);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;display.setCurrent(alert);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;recordstore.closeRecordStore();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;catch&nbsp;(Exception&nbsp;error)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alert&nbsp;=&nbsp;new&nbsp;Alert(&#8220;Error&nbsp;Closing&#8221;,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;error.toString(),&nbsp;null,&nbsp;AlertType.WARNING);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alert.setTimeout(Alert.FOREVER);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;display.setCurrent(alert);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(RecordStore.listRecordStores()&nbsp;!=&nbsp;null)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RecordStore.deleteRecordStore(&#8220;myRecordStore&#8221;);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;recordEnumeration.destroy();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;catch&nbsp;(Exception&nbsp;error)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alert&nbsp;=&nbsp;new&nbsp;Alert(&#8220;Error&nbsp;Removing&#8221;,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;error.toString(),&nbsp;null,&nbsp;AlertType.WARNING);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alert.setTimeout(Alert.FOREVER);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;display.setCurrent(alert);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}class&nbsp;Comparator&nbsp;implements&nbsp;RecordComparator{&nbsp;&nbsp;public&nbsp;int&nbsp;compare(byte[]&nbsp;record1,&nbsp;byte[]&nbsp;record2)&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;String&nbsp;string1&nbsp;=&nbsp;new&nbsp;String(record1),&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;string2=&nbsp;new&nbsp;String(record2);&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;comparison&nbsp;=&nbsp;string1.compareTo(string2);&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(comparison&nbsp;==&nbsp;0)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;RecordComparator.EQUIVALENT;&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;if&nbsp;(comparison&nbsp;&lt;&nbsp;0)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;RecordComparator.PRECEDES;&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;RecordComparator.FOLLOWS;&nbsp;&nbsp;}}<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-317","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/317","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=317"}],"version-history":[{"count":0,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/317\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=317"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=317"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=317"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}