×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Oct 2007
    Location
    Noida
    Posts
    152

    Question Recordstore !!Recordstore !! where are you ?

    hi All,
    I am posting my request again as i was not able to resolve it the first time.

    I am creating two midlets in a single jar file.

    Midlet-A & Midlet-B

    Midlet-A has the responsibility of writing into a recordstore and reading from the same which is working perfectly fine.
    Code:
    /*
     * MidletA.java
     *
     * Created on March 27, 2009, 11:47 AM
     */
    
    import java.io.ByteArrayOutputStream;
    import java.io.DataOutputStream;
    import java.util.Vector;
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.rms.RecordStore;
    /**
     *
     * @author  AbhishekKarmakar
     */
    public class MidletA extends MIDlet
    {
        public void startApp()
        {
            Form form = new Form("A");
            Display display = Display.getDisplay(this);
            try
            {
                RecordStore rs_one = null;
                rs_one = RecordStore.openRecordStore("ABC",true);
                rs_one.addRecord("hi this is a test".getBytes(),0,"hi this is a test".length());
                display.setCurrent(form);
                
                String a = new String(rs_one.getRecord(1));
                form.append("writing.." + a);
    
            }
            catch(Exception ex)
            {
                ex.toString();
            }
        }
        
        public void pauseApp()
        {
        }
        
        public void destroyApp(boolean unconditional)
        {
        }
    }

    Midlet-B is supposed to read from the recordstore that has already been created by Midlet-A. I execute Midlet-A in the emulator first and then restart the emulator to Start Midlet-B.

    Code:
    /*
     * Midletb.java
     *
     * Created on March 27, 2009, 11:50 AM
     */
    
    import java.io.ByteArrayInputStream;
    import java.io.DataInputStream;
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.rms.RecordStore;
    
    /**
     *
     * @author  AbhishekKarmakar
     * @version
     */
    public class Midletb extends MIDlet
    {
        public void startApp()
        {
            Form form = new Form("B");
            Display display = Display.getDisplay(this);
            try
            {
                
                RecordStore rs  = null;
                rs = RecordStore.openRecordStore("ABC",false);
                String a = new String(rs.getRecord(1));
                display.setCurrent(form);
                form.append("writing.." + a);
            }
            catch(Exception ex)
            {
                display.setCurrent(form);
                form.append("error" + ex.toString());
            }
        }
        public void pauseApp()
        {
        }
        public void destroyApp(boolean unconditional)
        {
        }
    }
    In case 1.
    Code:
    rs = RecordStore.openRecordStore("ABC",false);
    When i start Midlet-B it gives me "javax.microedition.rms.RecordStoreNotFoundException: cannot find record store file
    "

    in case 2.
    Code:
    rs = RecordStore.openRecordStore("ABC",true);
    it gives me this exception
    "javax.microedition.rms.InvalidRecordIDException
    "
    Abhishek karmakar

    never- Never - NEVER -- !!! NEVER !!! GIVE UP

  2. #2
    Super Contributor
    Join Date
    Apr 2007
    Posts
    2,708

    Re: Recordstore !!Recordstore !! where are you ?

    im not a 100% sure cause I havent used it much lately but shouldnt u Close the recordstore in Midlet A after you have written to it ?

  3. #3
    Registered User
    Join Date
    Oct 2007
    Location
    Noida
    Posts
    152

    Red face Re: Recordstore !!Recordstore !! where are you ?

    hi again,
    Well i tried it a lot on the Emulator but alas it was not working. Finally i tried it up in my phone (Nokia N70) and its working there. I think i just have the emulate the rest of the process in the phone. its sure gonna take a lot of time.
    Abhishek karmakar

    never- Never - NEVER -- !!! NEVER !!! GIVE UP

  4. #4
    Super Contributor
    Join Date
    Sep 2008
    Location
    Noida, U.P.
    Posts
    1,330

    Thumbs up Re: Recordstore !!Recordstore !! where are you ?

    Quote Originally Posted by Abhishek_karmakar View Post
    hi All,
    I am posting my request again as i was not able to resolve it the first time.

    I am creating two midlets in a single jar file.

    Midlet-A & Midlet-B

    Midlet-A has the responsibility of writing into a recordstore and reading from the same which is working perfectly fine.
    Code:
    /*
     * MidletA.java
     *
     * Created on March 27, 2009, 11:47 AM
     */
    
    import java.io.ByteArrayOutputStream;
    import java.io.DataOutputStream;
    import java.util.Vector;
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.rms.RecordStore;
    /**
     *
     * @author  AbhishekKarmakar
     */
    public class MidletA extends MIDlet
    {
        public void startApp()
        {
            Form form = new Form("A");
            Display display = Display.getDisplay(this);
            try
            {
                RecordStore rs_one = null;
                rs_one = RecordStore.openRecordStore("ABC",true);
                rs_one.addRecord("hi this is a test".getBytes(),0,"hi this is a test".length());
                display.setCurrent(form);
                
                String a = new String(rs_one.getRecord(1));
                form.append("writing.." + a);
    
            }
            catch(Exception ex)
            {
                ex.toString();
            }
        }
        
        public void pauseApp()
        {
        }
        
        public void destroyApp(boolean unconditional)
        {
        }
    }

    Midlet-B is supposed to read from the recordstore that has already been created by Midlet-A. I execute Midlet-A in the emulator first and then restart the emulator to Start Midlet-B.

    Code:
    /*
     * Midletb.java
     *
     * Created on March 27, 2009, 11:50 AM
     */
    
    import java.io.ByteArrayInputStream;
    import java.io.DataInputStream;
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.rms.RecordStore;
    
    /**
     *
     * @author  AbhishekKarmakar
     * @version
     */
    public class Midletb extends MIDlet
    {
        public void startApp()
        {
            Form form = new Form("B");
            Display display = Display.getDisplay(this);
            try
            {
                
                RecordStore rs  = null;
                rs = RecordStore.openRecordStore("ABC",false);
                String a = new String(rs.getRecord(1));
                display.setCurrent(form);
                form.append("writing.." + a);
            }
            catch(Exception ex)
            {
                display.setCurrent(form);
                form.append("error" + ex.toString());
            }
        }
        public void pauseApp()
        {
        }
        public void destroyApp(boolean unconditional)
        {
        }
    }
    In case 1.
    Code:
    rs = RecordStore.openRecordStore("ABC",false);
    When i start Midlet-B it gives me "javax.microedition.rms.RecordStoreNotFoundException: cannot find record store file
    "

    in case 2.
    Code:
    rs = RecordStore.openRecordStore("ABC",true);
    it gives me this exception
    "javax.microedition.rms.InvalidRecordIDException
    "
    its obvious buddy. when u run the midlet B with the parameter = false at the time of recordstore opening, midlet B not found the recordstore and exception comes for the same. When u run midlet B with true that means recordstore will creates if not found, so recordstore will create but its empty and what u did, u read the first record from the empty recordstore. definitely it gives record ID exception. So whats ur problem ? well before reading the RMS u can check that whether the recordstore is empty or not. If not then read the records of recordstore.
    thanks,
    jitu_goldie..

    KEEP TRYING..

Similar Threads

  1. Delete Record from RecordStore
    By mobileben in forum Mobile Java General
    Replies: 6
    Last Post: 2012-07-27, 08:27
  2. RecordStore bug on Series 60
    By ncerezo2 in forum Mobile Java General
    Replies: 21
    Last Post: 2009-11-26, 10:12
  3. J2ME Nokia 6263 RecordStore issue
    By jbaisden in forum Mobile Java General
    Replies: 0
    Last Post: 2008-02-20, 05:28
  4. Series40 RecordStore limitations unclear
    By bongio67 in forum Mobile Java General
    Replies: 0
    Last Post: 2004-12-16, 17:23
  5. RecordStore problem with 3100 (OS v 2.74)?
    By ericprat in forum Mobile Java General
    Replies: 4
    Last Post: 2003-09-11, 20:55

Posting Permissions

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