public void showFirstRecord() { fmFirstRecord = new Form("First Record"); String name = "Nenacetl jsem"; int number = 0; try { byte[] record = rs.getRecord(1); ByteArrayInputStream buffer = new ByteArrayInputStream(record); DataInputStream dis = new DataInputStream(buffer); name = dis.readUTF(); number = dis.readInt(); dis.close(); } catch (Exception e) { } fmFirstRecord.append(name + " " + String.valueOf(number)); // fmFirstRecord.append(String.valueOf(number)); fmFirstRecord.setCommandListener(this); fmFirstRecord.addCommand(cmdMenu); dsp.setCurrent(fmFirstRecord); }
/** Get the settings the Manager saved for the user. */ private void restoreSettings() { ByteArrayInputStream bas; DataInputStream dis; byte[] data; RecordStore settings = null; try { settings = RecordStore.openRecordStore(GraphicalInstaller.SETTINGS_STORE, false); data = settings.getRecord(1); if (data != null) { bas = new ByteArrayInputStream(data); dis = new DataInputStream(bas); defaultInstallListUrl = dis.readUTF(); } } catch (RecordStoreException e) { if (Logging.REPORT_LEVEL <= Logging.WARNING) { Logging.report( Logging.WARNING, LogChannels.LC_AMS, "restoreSettings threw a RecordStoreException"); } } catch (IOException e) { if (Logging.REPORT_LEVEL <= Logging.WARNING) { Logging.report(Logging.WARNING, LogChannels.LC_AMS, "restoreSettings threw an IOException"); } } finally { if (settings != null) { try { settings.closeRecordStore(); } catch (RecordStoreException e) { if (Logging.REPORT_LEVEL <= Logging.WARNING) { Logging.report( Logging.WARNING, LogChannels.LC_AMS, "closeRecordStore threw a RecordStoreException"); } } } } }
public void editRecord(int record_num) { fmEditRecord = new Form("Edit Record"); String name = "Nenacetl jsem"; int number = 0; try { byte[] record = rs.getRecord(record_num); ByteArrayInputStream buffer = new ByteArrayInputStream(record); DataInputStream dis = new DataInputStream(buffer); name = dis.readUTF(); number = dis.readInt(); dis.close(); } catch (Exception e) { } txfName = new TextField("Name", name, 10, TextField.ANY); txfNumber = new TextField("Number", String.valueOf(number), 10, TextField.NUMERIC); fmEditRecord.append(txfName); fmEditRecord.append(txfNumber); fmEditRecord.addCommand(cmdEdit); fmEditRecord.addCommand(cmdMenu); fmEditRecord.setCommandListener(this); dsp.setCurrent(fmEditRecord); }