Pemrograman Mobile RMS (Record Managements System

)

Oleh : I Putu Mahendra Pramadhitya (1104505027)

Jurusan Teknologi Informasi Fakultas Teknik Universitas Udayana 2013
RMS (record managements system) merupakan kombinasi antara file system dan database management system yang dapat kita gunakan untuk menyimpan data dalam bentuk

Berikut adalah Menampilkan Nama dengan menggunakan Text Field -> String Item dari Form 1 Kedalam Form 2 . sama dengan struktur data pada tabel dalam sebuah database. berikut contohnya : 1.baris dan kolom. setelah itu click dan drag dari Form 1 ke Form seperti berikut : • Diperlukannya relasi dari OkCommand ( ke Form1 ) yang dimana bila kita menekan tombol OK pada applikasi Mobile tersebut maka dia akan masuk ke Form berikutnya dan sebaliknya BackCommand diperlukan untuk mengembalikan ke Form sebelumnya . Screen View Program • Form Input Data . EXIT dari Form tersebut . Flow View Program • Masukan Back Command pada Form1 yang diman command back diperlukan untuk memgembalikan / back ke form sebelumnya . • Terdapat 2 Form yang akan digunakan seperti yang diatas dan diisi command untuk OK . Setelah itu masuk kedalam Form itu sendiri yang dimana seperti berikut : 2. BACK .

• Form Output Data 3. Kode program .

private Command backCommand2. */ import javax./* * To change this template. . The method is called before the * <code>startMIDlet</code> method.microedition. private Command exitCommand.*. private Command backCommand3. private Command backCommand1. private Command backCommand. It is called only once when the MIDlet is * started. static final String REC_STORE = "ReadWriteRMS".microedition.*. */ public dataRMS() { } //<editor-fold defaultstate="collapsed" desc=" Generated Methods "> //</editor-fold> //<editor-fold defaultstate="collapsed" desc=" Generated Method: initialize "> /** * Initializes the application. import javax. //</editor-fold> /** * The dataRMS constructor. private Form form1. private RecordStore rs = null.lcdui.*. private TextField textField. //<editor-fold defaultstate="collapsed" desc=" Generated Fields "> private Form form.rms. private Command exitCommand1. /** * @author toshiba */ public class dataRMS extends MIDlet implements CommandListener { private boolean midletPaused = false. private Command exitCommand2.midlet. import javax. private Command backCommand4. private StringItem stringItem. choose Tools | Templates * and open the template in the editor.microedition. private Command okCommand.

* * @param alert the Alert which is temporarily set to the display. */ public void resumeMIDlet() { // write pre-action user code here // write post-action user code here } //</editor-fold> //<editor-fold defaultstate="collapsed" desc=" Generated Method: switchDisplayable "> /** * Switches a current displayable in a display.*/ private void initialize() { // write pre-initialize user code here // write post-initialize user code here } //</editor-fold> //<editor-fold defaultstate="collapsed" desc=" Generated Method: startMIDlet "> /** * Performs an action assigned to the Mobile Device MIDlet Started point. getForm()). then <code>nextDisplayable</code> is set * immediately * @param nextDisplayable the Displayable to be set */ . */ public void startMIDlet() { // write pre-action user code here switchDisplayable(null. // write post-action user code here } //</editor-fold> //<editor-fold defaultstate="collapsed" desc=" Generated Method: resumeMIDlet "> /** * Performs an action assigned to the Mobile Device MIDlet Resumed point. * if <code>null</code>. This method is used by all actions in the * design for switching displayable. The * <code>display</code> instance is taken from * <code>getDisplay</code> method.

// write post-action user code here } } // write post-action user code here } . writeRecord(textField. openRecord(). } } else if (displayable == form1) { if (command == backCommand2) { // write pre-action user code here switchDisplayable(null. * * @param command the Command that was invoked * @param displayable the Displayable where the command was invoked */ public void commandAction(Command command. nextDisplayable). Displayable nextDisplayable) { // write pre-switch user code here Display display = getDisplay().getString()). } // write post-switch user code here } //</editor-fold> //<editor-fold defaultstate="collapsed" desc=" Generated Method: commandAction for Displayables "> /** * Called by a system to indicated that a command has been invoked on a * particular displayable. // write post-action user code here } else if (command == okCommand) { switchDisplayable(null.public void switchDisplayable(Alert alert. // write post-action user code here } else if (command == exitCommand) { // write pre-action user code here exitMIDlet(). getForm1()). getForm()). if (alert == null) { display.setCurrent(nextDisplayable). readRecords().setCurrent(alert. } else { display. Displayable displayable) { // write pre-action user code here if (displayable == form) { if (command == exitCommand2) { // write pre-action user code here exitMIDlet().

* * @return the initialized component instance */ public Form getForm1() { if (form1 == null) { // write pre-init user code here form1 = new Form("Hasil".addCommand(getBackCommand2()).setCommandListener(this). } //</editor-fold> //<editor-fold defaultstate="collapsed" desc=" Generated Getter: backCommand "> /** * Returns an initialized instance of backCommand component. form1.setCommandListener(this).addCommand(getExitCommand()). form. // write post-init user code here } return form. form1.//</editor-fold> //<editor-fold defaultstate="collapsed" desc=" Generated Getter: form "> /** * Returns an initialized instance of form component. form. form. } //</editor-fold> //<editor-fold defaultstate="collapsed" desc=" Generated Getter: form1 "> /** * Returns an initialized instance of form1 component. form1. * * @return the initialized component instance */ public Form getForm() { if (form == null) { // write pre-init user code here form = new Form("masukan data". // write post-init user code here } return form1.addCommand(getOkCommand()). new Item[] {getTextField()}). * . new Item[] {getStringItem()}).addCommand(getExitCommand2()).

// write post-init user code here } return okCommand. 0).BACK. * * @return the initialized component instance */ public Command getBackCommand1() { if (backCommand1 == null) { // write pre-init user code here backCommand1 = new Command("Back". * * @return the initialized component instance */ public Command getOkCommand() { if (okCommand == null) { // write pre-init user code here okCommand = new Command("Ok". 0). // write post-init user code here } return backCommand.* @return the initialized component instance */ public Command getBackCommand() { if (backCommand == null) { // write pre-init user code here backCommand = new Command("Back".BACK. Command. } //</editor-fold> //<editor-fold defaultstate="collapsed" desc=" Generated Getter: okCommand "> /** * Returns an initialized instance of okCommand component. // write post-init user code here } return backCommand1. } //</editor-fold> //<editor-fold defaultstate="collapsed" desc=" Generated . 0). Command. Command. } //</editor-fold> //<editor-fold defaultstate="collapsed" desc=" Generated Getter: backCommand1 "> /** * Returns an initialized instance of backCommand1 component.OK.

Command. 0). 32.ANY).Getter: textField "> /** * Returns an initialized instance of textField component. // write post-init user code here } . // write post-init user code here } return stringItem. * * @return the initialized component instance */ public Command getBackCommand2() { if (backCommand2 == null) { // write pre-init user code here backCommand2 = new Command("Back". ""). * * @return the initialized component instance */ public StringItem getStringItem() { if (stringItem == null) { // write pre-init user code here stringItem = new StringItem("". } //</editor-fold> //<editor-fold defaultstate="collapsed" desc=" Generated Getter: stringItem "> /** * Returns an initialized instance of stringItem component. TextField. // write post-init user code here } return textField. * * @return the initialized component instance */ public TextField getTextField() { if (textField == null) { // write pre-init user code here textField = new TextField("Input Data".BACK. } //</editor-fold> //<editor-fold defaultstate="collapsed" desc=" Generated Getter: backCommand2 "> /** * Returns an initialized instance of backCommand2 component. "".

Command. } //</editor-fold> //<editor-fold defaultstate="collapsed" desc=" Generated Getter: exitCommand "> /** * Returns an initialized instance of exitCommand component. * * @return the initialized component instance */ public Command getExitCommand1() { . // write post-init user code here } return exitCommand. 0).EXIT.BACK. } //</editor-fold> //<editor-fold defaultstate="collapsed" desc=" Generated Getter: backCommand3 "> /** * Returns an initialized instance of backCommand3 component. } //</editor-fold> //<editor-fold defaultstate="collapsed" desc=" Generated Getter: exitCommand1 "> /** * Returns an initialized instance of exitCommand1 component. * * @return the initialized component instance */ public Command getExitCommand() { if (exitCommand == null) { // write pre-init user code here exitCommand = new Command("Exit". * * @return the initialized component instance */ public Command getBackCommand3() { if (backCommand3 == null) { // write pre-init user code here backCommand3 = new Command("Back". Command. // write post-init user code here } return backCommand3. 0).return backCommand2.

EXIT. * * @return the initialized component instance */ public Command getBackCommand4() { if (backCommand4 == null) { // write pre-init user code here backCommand4 = new Command("Back".EXIT. * * @return the initialized component instance */ public Command getExitCommand2() { if (exitCommand2 == null) { // write pre-init user code here exitCommand2 = new Command("Exit". } //</editor-fold> //<editor-fold defaultstate="collapsed" desc=" Generated Getter: backCommand4 "> /** * Returns an initialized instance of backCommand4 component. Command. } //</editor-fold> //<editor-fold defaultstate="collapsed" desc=" Generated Getter: exitCommand2 "> /** * Returns an initialized instance of exitCommand2 component. // write post-init user code here } return exitCommand1.0). Command. 0).BACK. if (exitCommand1 == null) { // write pre-init user code here exitCommand1 = new Command("Exit". Command. * . // write post-init user code here } return backCommand4. // write post-init user code here } return exitCommand2. } //</editor-fold> /** * Returns a display instance. 0).

*/ public void exitMIDlet() { switchDisplayable(null.openRecordStore(REC_STORE. Checks whether the MIDlet have been * already started and initialize/starts or resumes the MIDlet. * * @param unconditional if true. */ public void pauseApp() { midletPaused = true. } /** * Called to signal the MIDlet to terminate. notifyDestroyed().getDisplay(this). } /** * Exits MIDlet. . destroyApp(true). */ public void startApp() { if (midletPaused) { resumeMIDlet(). } else { initialize().* @return the display instance. } /** * Called when MIDlet is started. startMIDlet(). } midletPaused = false. */ public void destroyApp(boolean unconditional) { } public void openRecord() { try { rs = RecordStore. then the MIDlet has to be unconditionally * terminated and all resources has to be released. null). */ public Display getDisplay() { return Display. } /** * Called when MIDlet is paused.

getRecordSize(i)).addRecord(rec. if (rs. } len = rs. 0. len).getRecordSize(i)]. Berikut adalah hasil running program proses input data dan output hasil : .true).setText(A).getRecordSize(i) > recData."). } catch (Exception e) { } } public void readRecords() { try { byte[] recData = new byte[8]. } } 4. choose Tools | Templates.getNumRecords(). 0. i++) { System. for (int i = 1.out.println(rs. int len. recData. i <= rs.getBytes(). try { rs. } } } catch (Exception e) { } private void writeRecord() { throw new UnsupportedOperationException("Not supported yet. String A = new String(recData. stringItem.println("Gagal"). //To change body of generated methods. } public void writeRecord(String str) { byte[] rec = str. 0). rec. } } catch (Exception e) { System.out.getRecord(i.length).length) { recData = new byte[rs.

Outuput Hasil .Gambar 1. Input data Gambar 2.