×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Regular Contributor
    Join Date
    Jul 2008
    Posts
    72

    interesting problem with RMS ... have a look..

    hi friends,

    while working with RMS i have encountered following error:
    Steps in my project:

    1. when the user inputs the value i have saved that in RMS.
    2. when the user moves to the next screen i have read the previously stored data from RMS.
    3. while reading, i can't read the previously inputted data. To read that I have to exit the application and restart it again, then only i can be able to read the previously inputted data.

    for your convenience I have written my code like this have a look:

    for saving record:

    public void savePinCode(String pinCode){
    try{
    byte[] outputRecord;
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    DataOutputStream outputDataStream = new DataOutputStream(outputStream);

    RecordStore recordStore = RecordStore.openRecordStore("EmpPinCode",true);

    outputDataStream.writeUTF(pinCode);
    outputDataStream.flush();

    outputRecord = outputStream.toByteArray();


    if(recordStore.getNumRecords() == 0){
    //recordStore.addRecord(bytes,0,bytes.length);
    recordStore.addRecord(outputRecord, 0, outputRecord.length);
    } else{//update existing(first) record
    recordStore.setRecord(1,outputRecord, 0, outputRecord.length);
    }
    recordStore.closeRecordStore();
    } catch(RecordStoreException e){
    //System.err.println("Could not save the Pin Code. Try again.");
    } catch(Exception e){

    }
    }


    for reading record:
    public String readPinCode(){
    String empCode = "0";
    try{
    byte[] outputRecord;


    RecordStore recordStore = RecordStore.openRecordStore("EmpPinCode",true);

    RecordEnumeration r = recordStore.enumerateRecords(null,null,true);

    int id = r.nextRecordId();
    ByteArrayInputStream bais = new ByteArrayInputStream(recordStore.getRecord(id));
    DataInputStream inputStream = new DataInputStream(bais);
    try {
    empCode = inputStream.readUTF();
    } catch (EOFException eofe) {
    return empCode;
    }

    recordStore.closeRecordStore();
    } catch(RecordStoreException e){
    //System.err.println("Could not save the Pin Code. Try again.");
    //return empCode;
    } catch(IOException ioe){
    //return empCode;
    }
    return empCode;
    }



    please let me know where i have to modify the code to read instantly.

    thanks

  2. #2
    Regular Contributor
    Join Date
    Jul 2008
    Posts
    53

    Re: interesting problem with RMS ... have a look..

    r u testing in emulator or on actual device? I suggest try on device.

  3. #3
    Regular Contributor
    Join Date
    Jun 2008
    Location
    Tel-Aviv,Israel
    Posts
    100

    Thumbs up Re: interesting problem with RMS ... have a look..

    An example of reading With Enumerator: you will be able to read it all.
    Code:
    ByteArrayInputStream inputStreamF = new ByteArrayInputStream(byteInputData);
    DataInputStream inputDataStreamF = new DataInputStream(inputStreamF);
    recordEnumeration = GetMenuData.rs.enumerateRecords(null, null, false);
    while (recordEnumeration.hasNextElement()) {
    GetMenuData.rs.getRecord(recordEnumeration.nextRecordId(),byteInputData, 0);
    ITEM_ID_O = inputDataStreamF.readUTF();
    ITEM_NAME_O = inputDataStreamF.readUTF();
    ITEM_POSITION_O = inputDataStreamF.readUTF();
    ITEM_TYPE_O = inputDataStreamF.readUTF();
    URL_O = inputDataStreamF.readUTF();
    PORT_O = inputDataStreamF.readUTF();

    Good Luch
    Yaniv

  4. #4
    Registered User
    Join Date
    Jan 2008
    Location
    Pune
    Posts
    24

    Re: interesting problem with RMS ... have a look..

    Hi AMishra,
    I have checked ur code with WTK25 and it is working fine.
    You may do one thing.. just delete your previous .db file from \WTK25\appdb\. directory and recompile the code.
    It may work fine.

    Anjan

  5. #5
    Regular Contributor
    Join Date
    Jul 2008
    Posts
    72

    Re: interesting problem with RMS ... have a look..

    Hi,

    It worked now thanks for ur help.

Similar Threads

  1. RMS data LOST problem in 3410!!!
    By bitsonic in forum Mobile Java General
    Replies: 6
    Last Post: 2009-03-27, 09:50
  2. RMS problem in Nokia 2630
    By jayesh1912 in forum Mobile Java General
    Replies: 2
    Last Post: 2008-04-10, 11:03
  3. Problem With RMS
    By satyarajasekhar in forum Mobile Java General
    Replies: 0
    Last Post: 2007-12-04, 08:17
  4. RMS problem in 6230i regarding available size
    By guylis in forum Mobile Java General
    Replies: 2
    Last Post: 2006-02-07, 16:01
  5. nokia 3410 RMS problem
    By tomazas in forum Mobile Java General
    Replies: 0
    Last Post: 2003-04-03, 12:31

Posting Permissions

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