×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Jan 2010
    Posts
    15

    Medicine App RMS problems

    Hi guys!
    I am building a medicine reminder app, i am using RMS to store the information-medicine name,dosage etc.
    The format i wanted is record[i]={String Medicine_name,int mornD,int aftD,int nitD,int mornDTime,int aftDTime,int nitDTime}
    I ve made two midlets-one that creates the record,one that list all the medicines stored.
    The problem here is the record stores only the first MEDICINE entry-i realized this when i used to input 3 medicines names
    and den go to the list medicine midlet, it would display only my first entry.
    I ve checked my code a hundred times i really cant figure out wats the problem

    THE ADD MEDICINE MODULE:
    Code:
     else if(command==saveCommand && displayable==setTimeForm)
        {
        int x=mornTim.getSelectedIndex();//there is choice group popup nd it gets selected index
        int y=aftTim.getSelectedIndex();//same
        int z=nitTim.getSelectedIndex();
        daysOfno=noOfDays.getString();
    
           try{
                
            rs=RecordStore.openRecordStore(REC_STORE, true);
             System.out.println("success in opening record");
            }catch(RecordStoreException e){System.out.println("Record could not be opened");}
    
            try{
             byte[] outputRecord;
            ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
            DataOutputStream outputDataStream =new DataOutputStream(outputStream);
            outputDataStream.writeUTF(nameOfMed);
            outputDataStream.writeInt(checkBoxSel[0]);//again there is a choice group if selected den value=1 else 0
            outputDataStream.writeInt(checkBoxSel[1]);
            outputDataStream.writeInt(checkBoxSel[2]);
            Integer myint1 = Integer.valueOf(m[x]);//basically in the popup choice group entry is in String this converts into int
            Integer myint2 = Integer.valueOf(a[y]);//m[x],a[y],n[z] are all int arrays nd each hold int value rep time e.g 8,9,10,11,12,1,2
            Integer myint3 = Integer.valueOf(n[z]);
            outputDataStream.writeInt(myint1.intValue());
            outputDataStream.writeInt(myint2.intValue());
            outputDataStream.writeInt(myint3.intValue());
            outputDataStream.flush();
            outputRecord = outputStream.toByteArray();
            rs.addRecord(outputRecord, 0, outputRecord.length);
            outputStream.reset();
            outputStream.close();
            outputDataStream.close();
            System.out.println("success in writing data");
            }
          catch ( Exception error)
          {
             System.out.print("Exception error");
          }
    
          try
          {
            rs.closeRecordStore();
          }
          catch (Exception error)
          {
            alert = new Alert("Error Closing",
                    error.toString(), null, AlertType.WARNING);
            alert.setTimeout(Alert.FOREVER);
            display.setCurrent(alert);
          }


    THE LIST MEDICINE MODULE:

    Code:
    String inputString=null; int i=-1;//i holds the index nd inputString[] holds list of all medicines saved in RMS
     public void startApp() {
            display=Display.getDisplay(this);
            form=new Form("LSIT OF ALL  MEDICINES");
             try
          {
           recordstore = RecordStore.openRecordStore("MEDICINES",false);
          }
          catch (Exception error)
          {
            alert = new Alert("Error Opening",error.toString(), null, AlertType.WARNING);
            alert.setTimeout(Alert.FOREVER);
            display.setCurrent(alert);
          }
    
            try
          {
            byte[] byteInputData = new byte[100];
            ByteArrayInputStream inputStream = new ByteArrayInputStream(byteInputData);
            DataInputStream inputDataStream =  new DataInputStream(inputStream);
            for (int x = 1; x <= recordstore.getNumRecords(); x++)
            {
             recordstore.getRecord(x, byteInputData, 0);
             form.append(inputDataStream.readUTF());//read only name of the medicine and append it to the form
             inputString[++i] = inputDataStream.readUTF();//save whatever read into the String array
             inputStream.reset();
            }
            inputStream.close();
            inputDataStream.close();
            
          }
          catch (Exception error)
          {
    
          }
    for(int j=1;j<i;j++)
                System.out.println(inputString[j]);//print med names on the console
    
            display.setCurrent(form);
    try
          {
            recordstore.closeRecordStore();
          }
          catch (Exception error)
          {
            alert = new Alert("Error Closing",
                    error.toString(), null, AlertType.WARNING);
            alert.setTimeout(Alert.FOREVER);
            display.setCurrent(alert);
          }
        }
    Last edited by deepakkinni; 2010-07-30 at 15:17.

  2. #2
    Nokia Developer Champion
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,344

    Re: Medicine App RMS problems

    Hi,

    I received your PM but I am not a Java ME person. I know little bit on Symbian C++.

    Let's hope someone from Java ME background helps you.
    Nokia Developer Wiki Moderation team

  3. #3
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: Medicine App RMS problems

    Really these lines are not clear at all..and hence before I made a post I want you to explain these in much more detailed manner..
    The problem here is the record stores only the first MEDICINE entry-i realized this when i used to input 3 medicines names
    and den go to the list medicine midlet, it would display only my first entry.
    I ve checked my code a hundred times i really cant figure out wats the problem
    I am not putting any guessing post including the answer....so please explain in order to make the reply as exact as possible.
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  4. #4
    Registered User
    Join Date
    Jan 2010
    Posts
    15

    Re: Medicine App RMS problems

    please check the code now, i have included comment lines for ease of understanding!

Similar Threads

  1. Medicine App
    By deepakkinni in forum Mobile Java General
    Replies: 6
    Last Post: 2010-07-28, 17:22
  2. Medicine reminder App
    By deepakkinni in forum General Development Questions
    Replies: 1
    Last Post: 2010-07-22, 15:21
  3. problems with rms
    By RafaelVN in forum Mobile Java General
    Replies: 2
    Last Post: 2008-06-14, 19:43
  4. RMS problems
    By mreaves in forum Mobile Java General
    Replies: 5
    Last Post: 2004-03-09, 12:34

Posting Permissions

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