×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User
    Join Date
    Oct 2012
    Posts
    2

    Question RecordStore (RMS) not implemented ? Nokia 2600c-2 (LE)

    Hi everyone!

    I'm developing application for this, pretty old, device - Nokia 2600c-2 (Lite Edition).

    I cannot use RMS! I successfully perform write operations, but there are no records after I start application the second time.

    I've tried setting parameter MIDlet-Data-Size to 8192 bytes (just a guess), but it didn't change anything.

    Please assist.

    P.S. Here's the device description: 2600_classic

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,751

    Re: RecordStore (RMS) not implemented ? Nokia 2600c-2 (LE)

    RMS is a mandatory feature, and your successful write operations also suggest that it is there. It may be a good idea to post some code here. Or you can also experiment with ready-made examples, for example this Wiki page, http://www.developer.nokia.com/Commu...t_System_(RMS) links a few. The SDK-s/WTK-s usually contain related examples too.

  3. #3
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,087

    Re: RecordStore (RMS) not implemented ? Nokia 2600c-2 (LE)

    Quote Originally Posted by 1mobdev View Post
    Hi everyone!
    I'm developing application for this, pretty old, device - Nokia 2600c-2 (Lite Edition).
    I cannot use RMS! I successfully perform write operations, but there are no records after I start application the second time.
    I've tried setting parameter MIDlet-Data-Size to 8192 bytes (just a guess), but it didn't change anything.
    Please assist.
    P.S. Here's the device description: 2600_classic
    As per the specs - 2600C is MIDP2.1 and CLDC 1.1 device: Which supports RMS along with below mentioned API's
    JSR 139 Connected, Limited Device Configuration (CLDC) 1.1
    JSR 118 MIDP 2.1
    JSR 185 Java™ Technology for Wireless Industry
    JSR 75 FileConnection and PIM API 1.0[1]
    JSR 82 Java™ APIs for Bluetooth 1.1[2]
    JSR 135 Mobile Media API 1.1[3]
    JSR 177 Security and Trust Services API for J2ME™ 1.0 (SATSA-APDU package)
    JSR 205 Wireless Messaging API 2.0
    Nokia UI API 1.1 Recommended Java SDK Series 40 5th Ed. FP1 Lite SDK

    Cut/Paste your RMS operations code-base, something looks wrong it it - you might be creating a new Record-store every-time instead of opening the existing one - please chk.
    thanks,
    ~Amitabh
    (Champion of the Month -Aug'13)
    Follow me on my blog for Innovative Mobile Apps

  4. #4
    Registered User
    Join Date
    Oct 2012
    Posts
    2

    Re: RecordStore (RMS) not implemented ? Nokia 2600c-2 (LE)

    Quote Originally Posted by wizard_hu_ View Post
    RMS is a mandatory feature, and your successful write operations also suggest that it is there. It may be a good idea to post some code here. Or you can also experiment with ready-made examples, for example this Wiki page, http://www.developer.nokia.com/Commu...t_System_(RMS) links a few. The SDK-s/WTK-s usually contain related examples too.
    It seems that I was wrong - the example source code that you have provided via wiki-links is working fine on my device.
    ----ReadWriteRMS.java----
    Code:
    package org.mvsys.rms.test;
    
    /*
    * http://www.developer.nokia.com/Community/Wiki/How_to_store_Data_in_RMS
    */
    
    import javax.microedition.lcdui.*;
    import javax.microedition.midlet.MIDlet;
    
    public class ReadWriteRMS extends MIDlet implements CommandListener {
    
       private Display display;
       private Alert alert;
       private Form form;
       private Command exit;
       private Command write;
       private Command read;
       private Command delete;
       private WrapRMS wrap;
    
       public ReadWriteRMS() {
          display = Display.getDisplay(this);
          wrap = new WrapRMS();
          exit = new Command("Exit", Command.EXIT, 1);
          write = new Command("Write", Command.SCREEN, 1);
          read = new Command("Read", Command.SCREEN, 2);
          delete = new Command("Delete", Command.SCREEN, 3);
          form = new Form("Mixed Record");
          form.addCommand(exit);
          form.addCommand(write);
          form.addCommand(read);
          form.addCommand(delete);
    
          form.setCommandListener(this);
       }
    
       public void startApp() {
          display.setCurrent(form);
       }
    
       public void pauseApp() {
       }
    
       public void destroyApp(boolean unconditional) {
       }
    
       public void commandAction(Command command, Displayable displayable) {
    
          // EXIT
          if (command == exit) {
             destroyApp(true);
             notifyDestroyed();
          }
          // WRITE
          else
             if (command == write) {
                try {
                   wrap.openRecordStore();
                }
                catch (Exception e) {
                   Log.showAlert(display, "" + e);
                }
                try {
                   wrap.writeRecords();
                }
                catch (Exception e) {
                   Log.showAlert(display, "" + e);
                }
                try {
                   wrap.closeRecordStore();
                }
                catch (Exception e) {
                   Log.showAlert(display, "" + e);
                }
             }
             // READ
             else
                if (command == read) {
                   try {
                      wrap.openRecordStore();
                   }
                   catch (Exception e) {
                      Log.showAlert(display, "" + e);
                   }
                   try {
                      String read = wrap.readRecords();
                      Log.showAlert(display, read);
                   }
                   catch (Exception e) {
                      Log.showAlert(display, "" + e);
                   }
                   try {
                      wrap.closeRecordStore();
                   }
                   catch (Exception e) {
                      Log.showAlert(display, "" + e);
                   }
                }
                // DELETE
                else
                   if (command == delete) {
                      try {
                         wrap.deleteStore();
                      }
                      catch (Exception e) {
                         Log.showAlert(display, "" + e);
                      }
                   }
       }
    
    }
    ----WrapRMS.java----
    Code:
    package org.mvsys.rms.test;
    
    import javax.microedition.rms.RecordStore;
    import java.io.ByteArrayInputStream;
    import java.io.ByteArrayOutputStream;
    import java.io.DataInputStream;
    import java.io.DataOutputStream;
    
    public class WrapRMS {
       private RecordStore recordstore = null;
       private final String myStoreName = "myRecordStore";
    
       public WrapRMS() {
       }
    
       public void openRecordStore() throws Exception {
          try {
             recordstore = RecordStore.openRecordStore(myStoreName, true);
          }
          catch (Exception error) {
             throw new Exception("Error Creating: " + error);
          }
       }
    
       public void closeRecordStore() throws Exception {
          try {
             recordstore.closeRecordStore();
          }
          catch (Exception error) {
             throw new Exception("Error Closing: " + error);
          }
       }
    
       public void writeRecords() throws Exception {
          try {
             byte[] outputRecord;
    
             String outputString[] = {"why_you", "Changed", "my_names", "andAdded", "your", "name"};
             int outputInteger[] = {25, 21, 20, 23, 34, 34};
             boolean outputBoolean[] = {true, false, true, true, false, true};
    
             ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
             DataOutputStream outputDataStream = new DataOutputStream(outputStream);
    
             for (int i = 0; i < outputString.length; i++) {
                outputDataStream.writeUTF(outputString[i]);
                outputDataStream.writeBoolean(outputBoolean[i]);
                outputDataStream.writeInt(outputInteger[i]);
                outputDataStream.flush();
                outputRecord = outputStream.toByteArray();
                recordstore.addRecord(outputRecord, 0, outputRecord.length);
             }
    
             outputStream.reset();
             outputStream.close();
             outputDataStream.close();
          }
          catch (Exception error) {
             throw new Exception("Error Writing: " + error);
          }
       }
    
       public String readRecords() throws Exception {
          StringBuffer buffer = new StringBuffer();
          try {
    
             byte[] byteInputData = new byte[100];
             ByteArrayInputStream inputStream = new ByteArrayInputStream(byteInputData);
             DataInputStream inputDataStream = new DataInputStream(inputStream);
             int numrec = recordstore.getNumRecords();
             buffer.append(" Num rec " + numrec);
             buffer.append("\n");
             for (int i = 1; i <= numrec; i++) {
    
                recordstore.getRecord(i, byteInputData, 0);
                buffer.append(inputDataStream.readUTF());
                buffer.append("\n");
                buffer.append(inputDataStream.readBoolean());
                buffer.append("\n");
                buffer.append(inputDataStream.readInt());
                buffer.append("\n");
    
             }
    
             inputStream.close();
             inputDataStream.close();
          }
          catch (Exception error) {
             throw new Exception("Error Reading: " + error);
          }
    
          return "Reading: " + buffer.toString();
       }
    
       public void deleteStore() throws Exception {
          if (RecordStore.listRecordStores() != null) {
             try {
                RecordStore.deleteRecordStore(myStoreName);
             }
             catch (Exception error) {
                throw new Exception("Error Removing: " + error);
             }
          }
       }
    }
    ----Log.java----
    Code:
    package org.mvsys.rms.test;
    
    import javax.microedition.lcdui.Alert;
    import javax.microedition.lcdui.AlertType;
    import javax.microedition.lcdui.Display;
    
    public class Log {
       public static void showAlert(Display d, String body) {
          Alert alert = new Alert("Log", body, null, AlertType.WARNING);
          alert.setTimeout(Alert.FOREVER);
          d.setCurrent(alert);
       }
    }
    I guess, that there's something wrong with my project.

    P.S. the code above is not the project, of course

  5. #5
    Registered User
    Join Date
    Mar 2003
    Posts
    4,105
    You do close your RecordStore, do you?

  6. #6
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: RecordStore (RMS) not implemented ? Nokia 2600c-2 (LE)

    You must close a recordstore, or information will not persist on many implementations.

    I very strongly recommend that you do not keep recordstores open for a long period of time, and do not use instance variables to reference recordstores.

    I don't think your "wrapper" class is adding anything. Mainly, it catches the specific exceptions that the RMS methods throw (which would tell other parts of your applicastion why you had a problem), and throws a generic, less useful Exception instead.

    I'd suggest something more like:

    Code:
    public void addRecord(byte[] data) throws RecordStoreException {
        RecordStore rs = RecordStore.openRecordStore(RECORD_STORE_NAME, true);
        try {
            rs.addRecord(data, 0, data.length);
        } finally {
            rs.closeRecordStore();
        }
    }
    Here, the recordstore is open only briefly. It always gets closed, because the close method call is in a finally{} clause to make sure it happens no matter what (even if an exception is thrown). The exception thrown from this is the original. If it's a RecordStoreFullException, it's easy for your application's UI code to detect this, and report it in a friendly way to the user, like "Phone is full!" rather than some scary technical message.

    Graham.

  7. #7
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: RecordStore (RMS) not implemented ? Nokia 2600c-2 (LE)

    Oh, some useful info on RMS... in the wiki.

  8. #8
    Registered User
    Join Date
    Apr 2013
    Posts
    12

    Re: RecordStore (RMS) not implemented ? Nokia 2600c-2 (LE)

    Quote Originally Posted by grahamhughes View Post
    Oh, some useful info on RMS... in the wiki.
    Useful link!

Similar Threads

  1. OTA Provisioning for S40 devices (Nokia 2600c, 6233 and 5140 express music)
    By rtirupati in forum General Development Questions
    Replies: 2
    Last Post: 2013-10-22, 12:02
  2. Replies: 4
    Last Post: 2011-09-24, 23:05
  3. Does Nokia 2600c have MMAPI support?
    By sunil_bhambani123 in forum Mobile Java Media (Graphics & Sounds)
    Replies: 4
    Last Post: 2009-04-27, 05:32
  4. InputStream.available() not implemented on Nokia
    By maxxrek in forum Mobile Java Networking & Messaging & Security
    Replies: 2
    Last Post: 2008-11-12, 15:33
  5. DRM v2 Implemented Nokia Model Please
    By pavanv1.0 in forum Digital Rights Management & Content Downloading
    Replies: 5
    Last Post: 2007-05-30, 06:22

Posting Permissions

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