Results 1 to 3 of 3
  1. #1
    coldvoice05's Avatar
    coldvoice05 is offline Member
    Join Date
    Jul 2009
    Posts
    12
    Rep Power
    0

    Lightbulb dealing with database in wireless mobile midlet problem!

    given this example

    /*
    * RmsExample1.java
    *
    * (c) 2005 J.E.D.I.
    */

    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.rms.*;

    public class RmsExample1 extends MIDlet implements CommandListener {
    Display display;
    RecordStore recStore = null;
    int count = 0;

    public static final Command exitCommand =
    new Command("Exit", Command.EXIT, 1);
    public static final Command newCommand =
    new Command("New Record", Command.OK, 1);
    public static final Command deleteCommand =
    new Command("Delete Record", Command.OK, 1);

    ChoiceGroup items = new ChoiceGroup( "Items", Choice.MULTIPLE );

    public void startApp() {
    if( display == null ){
    display = Display.getDisplay( this );
    display.setCurrent(new RmsForm());
    loadStore();
    }
    }

    public void pauseApp() {}

    public void destroyApp(boolean unconditional){
    //
    Quit();
    }

    public void loadStore(){
    byte[] data = new byte[16];
    int recLength;
    items.deleteAll();

    try {
    // Open or Create Record Store with name "RmsExample1"
    recStore = RecordStore.openRecordStore("RmsExample1", true);

    // Load contents of Record Store
    for (int recId=1; recId<=recStore.getNumRecords(); recId++){
    // getRecord returns the length of the record
    recLength = recStore.getRecord(recId, data, 0);

    // Convert the byte array into String
    String item = new String(data, 0, recLength);

    // update the display
    items.append(item, null);
    }
    } catch (Exception e){items.append(e.toString(), null); }
    }

    class RmsForm extends Form {
    RmsForm(){
    // Setup the Form
    super("RmsExample");
    addCommand(exitCommand);
    addCommand(newCommand);
    addCommand(deleteCommand);
    setCommandListener(RmsExample1.this);
    append(items);
    }
    }


    public void commandAction(Command c, Displayable d){
    if(c == exitCommand){
    Quit();
    }
    if (c == newCommand){
    try {
    // We will create a new Record
    // This is the String we will put into the Record
    String newItem = "Record #" + recStore.getNextRecordID();

    // Convert the String into a byte array
    byte[] bytes = newItem.getBytes();

    // Write the Record into the Store
    recStore.addRecord(bytes, 0, bytes.length);

    // Update our display
    items.append(newItem, null);
    } catch (Exception e){}
    }
    if (c == deleteCommand){
    try {
    // We will create a new Record
    // This is the String we will put into the Record
    recStore.deleteRecord(recStore.getNextRecordID()-1);
    items.delete (items.size()-1);
    } catch (Exception e){}
    }
    }

    public void Quit(){
    if (recStore != null){
    try {
    recStore.closeRecordStore();
    } catch (RecordStoreNotOpenException notopen){
    // record store is not open
    } catch (RecordStoreException rse){
    // record store-related exception occurred
    }
    }
    // Exit
    notifyDestroyed();
    }
    }
    1) Improve the program such that records a listed not using a sequential for loop.

    2) Improve the checkboxes such that if it is checked then upon clicking delete only the checked items are deleted.

    3) You should be able to delete 1 or more list items at a single instance.

    Improve your program this time that is create the contents of each record based on the inputs of the users in the text field based on the given requirements:
    1) The program will have three interfaces: Main interface, Add record interface and Delete Record interface.
    2) The main interface will have a welcome screen and two choices add record and delete record with an EXIT and LAUNCH button.
    3) The add record interface will result to 2 text boxes namely name and cellphone with two menu buttons BACK (which will return the main interface) and ADD which will create the record based on the content inputted in the textfield.
    4) The delete record interface will list all the records created in checkbox list and the same as Machine problem 6 the user will just select the records to be deleted by selecting the checkbox and Delete button. It should also have a BACK button the will return to the main interface.

    Hint bench mark on your MP #6, hence make sure your MP #6 is already functioning as prescribed.

    PLEASE HELP ME IN THIS WORK TO DO... IM JUST A WOMAN AND WEAK WHEN IT COMES TO PROGRAMMING PLEASE HELP!!!

    THANK YOU GENTLEMEN =)
    Last edited by coldvoice05; 09-23-2009 at 08:25 AM.

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    What have you done so far and where are you stuck?

  3. #3
    coldvoice05's Avatar
    coldvoice05 is offline Member
    Join Date
    Jul 2009
    Posts
    12
    Rep Power
    0

    Unhappy

    Im stuck at nothing.. im sorry im just familiar with java application programming and Im not familiar with the key terms and codes in java midlet... its kinda different

    so i hope someone can help me here... I'm working while studying thats why I really need to pass this subject (sad)

Similar Threads

  1. wireless mobile midlet problem
    By coldvoice05 in forum Sun Java Wireless Toolkit
    Replies: 1
    Last Post: 02-14-2010, 01:54 PM
  2. Dealing with iReport 3.0.0
    By HotEvilGirl in forum New To Java
    Replies: 6
    Last Post: 09-11-2009, 11:32 AM
  3. Replies: 1
    Last Post: 08-07-2009, 12:14 PM
  4. Inconsistencies dealing with null
    By xcallmejudasx in forum New To Java
    Replies: 3
    Last Post: 05-11-2009, 08:58 PM
  5. Replies: 0
    Last Post: 11-06-2008, 09:07 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •