Enumeration & Deteling records in an RMS

insert this in the startApp method.
try
            RecordStore rs = RecordStore.openRecordStore("name", true);
            RecordEnumeration re = rs.enumerateRecords(null, null, true);
            String one = "a";
            String two = "b";
            String three = "c";
            String[][] x = new String[3][3];
            byte[] b;
            System.out.println(rs.getNextRecordID());
            b = one.getBytes();
            rs.addRecord(b, 0, b.length);
            System.out.println(rs.getNextRecordID());
            b = two.getBytes();
            rs.addRecord(b, 0, b.length);
            System.out.println(rs.getNextRecordID());
            b = three.getBytes();
            rs.addRecord(b, 0, b.length);
            System.out.println(rs.getNextRecordID());
            rs.deleteRecord(1);
            re.rebuild();
            System.out.println(re.isKeptUpdated());
            System.out.println(re.nextRecordId());
            //System.out.println(re.previousRecordId());
            System.out.println(re.numRecords());
        catch (RecordStoreException ex) {
            ex.printStackTrace();
        }why isnt this working? I read the documentation. It said that if i set the update to true i might face performance but at least i guarantee i wont get bad results when sorting or searching. so how come the num of records (last line) is 2? i entered 4 records. i deleted record number 1. so i expect to get 2,3,4 when i run the second print line 4 times. but i didnt. i got an invalididexception. i tried hte last print line and surprisingly i only have 2 records which explains why i got the exception.
i even read about rebuild.
im trying to implement a delete funciton on records in my store.

A THOUSAND APOLOGIES!!!! I JUST COUNTED HOW MANY TIMES I INSERTED RECORDS
EDIT: here's a REAL question.
here's what i no. rebuild is like 'reinitializing' the recordnum. ur using an existing one. renum setting its 3rd parameter to true is a good thing tho it might come at a cost of performance.
try
            RecordStore rs = RecordStore.openRecordStore("name", true);
            String one = "a", two = "b", three = "c", four = "d", five = "e", six = "f";
            /*remove this line*/RecordEnumeration re = rs.enumerateRecords(null, null, true);
            byte[] b;
            b = one.getBytes();
            rs.addRecord(b, 0, b.length);
            b = two.getBytes();
            rs.addRecord(b, 0, b.length);
            b = three.getBytes();
            rs.addRecord(b, 0, b.length);
            rs.deleteRecord(1);
            b = four.getBytes();
            rs.addRecord(b, 0, b.length);
            b = five.getBytes();
            rs.addRecord(b, 0, b.length);
            rs.deleteRecord(4);
            /*add that line here*/
            ///*COMMENT1:*/ re.rebuild();
            while(re.hasNextElement())
                System.out.println(re.nextRecordId());
                b = re.nextRecord();
                System.out.println(b.toString());
         }if i remove enum line and add it where i mentioned in the comment, then i get a result of 2 then nameofbyteinstring then 5 then invalididexception
if i remove the COMMENT1 comment and leave rebuild i get the same result
The current result is 5 then nameofbyteinstring then 2 then invalididexception. so rebuilding is a good thing.
now, can someone plz explain to me why im getting 5 after 2 let alone an exception? i thought it didnt jump through 'holes' but it did. but thts wierd. all i deleted were 2 records. wht happened to records 2 3 5 6? why did it jump from 2 to 5?
how do i fix this?
EDIT HERE LOOK HERE
any chance the reason why im getting an invalididexception is because re.nextRecord and .nextRecordID actually move the pointer to the next record and get the information? so what really happened is tht i printed the id of 2, the string representation of 4 and then the id of 5? cuz thts what it looks like. i ran the loop with only one print statement (id) and i got 2 3 5. i tried nextrecord alone and i got 3 strin names of the byte objects.
so this isnt like a while where u keep the pointer where it is and look ahead at the next record to find out if its null.
so there are two slutoins to track this
either have two recordenumerators, one for nextrecord, the other for nextrecordid
OR
whenever the list iof records is created i create a vector or array where i insert the index of each record. everytime i delete the record, i update the vector/array by removing it from the list.
any other third solution? thanx
Edited by: WildHeart on Apr 28, 2010 4:11 PM
Edited by: WildHeart on Apr 28, 2010 4:34 PM

Similar Messages

  • Retrive record id from rms?

    I need to know which id a record has in rms, and since there is no method for this, how do I do it? In this eksempel taken from sun's hp id is stored in a vector:
    Vector recordIDs = new Vector();
    int lastID = 1;
    //Add a record....parameters are missing here
    db.addRecord();
    // Now add the ID to the vector
    recordIDs.addElement(new Integer(++lastID));
    Now what I dont understand is that, when the applikation is closed the data in vector i losted and then what? Am I misunderstanding something?

    RecordEnumeration RecordStore.enumerateRecords(RecordFilter filter, RecordComparator comparator, boolean keepUpdated)
    seems like the method to use. Allows you to find all the record IDs in a RecordStore.

  • Content Server records

    Hi guys,
    I have an ECC system (SAP ERP 6.0 EHP6) whereby among many functionalities, Record Management System (RMS) is used. Various RMS attachments like jpeg, pdf and doc are stored in Content Server. Normally, we access these attachments thru docid. The attachments are saved in the MaxDB (version 7.6) database of the Content Server. I wish to know a few things regarding MaxDB content:
    How are the attachments kept in the MaxDB database? Can I view them in the database (like in Oracle we have BLOB fields)? I'm using Database Studio and SQL Studio for MaxDB. For example, in SQL Studio I can see 'schemas' DOMAIN, SUPERDBA and SYSINFO, each containing several tables. Which one contain the relevant tables? I suppose the docid is being kept in some table as well.
    regards.

    Hi Suraj,
    Refer to the information from thread http://scn.sap.com/thread/3352909
    You may perform SQL queries on tables starting with COMPONENTS*.
    Hope this helps
    Regards,
    Deepak Kori

  • Running out of ID in RMS?

    Adding a new record to a RMS will make the "next ID" incremented by 1.
    I just wonder what happens if there is ONLY ONE record, the current ID is MAX_INT, and I try to add a record to the RecordStore. Will it throw a RecordStoreFullException? Or will it compact and reindex the records?
    Thanks.

    arrhh...forget about this dumb question..

  • Can I assume internal format for RMS recordfilters?

    I am constructing the matches() routine to handle a recordfilter using two integers that are at the beginning of each record in the RMS. It runs much faster if I just compare the first eight bytes of the two byte arrays rather than constructing a ByteArrayInputStream and a DataInputStream so I can use the readInt method.
    Is it valid to assume that all phones will save integers as four bytes in the recordstore or is the internal format allowed to vary? I don't think big and little endian issues would arise because I am only checking for equality. But if the length varies or separators are added, then my eight-byte assumption falls apart.

    Is it valid to assume that all phones will save
    integers as four bytes in the recordstore or is the
    internal format allowed to vary? Java is always network order, so it will be the same on all platforms. Otherwise the DataIn/OutputStreams would not work either.

  • FIFO in RMS

    Hello, everyone..
    I have a question regarding to the RMS..
    As i know, each record in RecordStore (RMS) has an integer identification number..
    Do you know how to set the total number of record for just let say 20 records???
    if the record reach 20, and the new record added, it will be 1st in the record..
    and the last record will be thrown from the record...
    Can anyone able to explain it to me and give some psedocode or snipplet of code?
    I will appreciate it...
    As i had tried many times, but failed...
    Thanks...

    You can implement this logic using the standard API. Before adding a new record, check the number of records in the record store ('getNumRecords'). If the number is greater than your limit, 20, then a) use setRecord instead of addRecord; you must determine which record to overwrite, or b) delete a record and the use addRecord.
    You have to consider how you select the record to be purged or overwritten.

  • Abstract class confusion

    I am writing a J2ME application, and I want to write a Record management system (RMS) that I can use in other J2ME programs. I have a Record class that RMS classes need to know about. The idea is that the Record class is abstract, and the implementation is defined by a subclass - depending on what the application needs to store. Any Record must provide the following:
    1) A constructor which takes a single byte[] parameter, which is the data read in from the RecordStore by the RMS. The implementation depends on what information is stored in this type of Record - it might be a String, series of ints, etc...
    2) A method getStorageFormat() which returns a btye[] representing the data to be stored in the RecordStore. Again, this is dependent on the application.
    I think that I have to use an abstract class here, so I have written an abstract class called Record - here's what it looks like:
    public abstract class Record {
         public Record(byte[] bytes) { }; //Should this be an empty constructor?
         public abstract byte[] getStorageFormat();
    }My problem is that I can't define a subclass of Record that works! Here's an example:
    public class MyRecord extends Record {
           String data1, data2, data3; //Some data that is stored in this record
           public MyRecord(byte[] bytes) {
                  String data = new String(bytes);
                  // do some processing to extract the data...
           public byte[] getStorageFormat() {
                  String sep = ","; //A seperator
                  String tmp = data1 + sep + data2 + sep + data3; //put all the data together with
                  return tmp.getBytes();
    }}I get an error in Eclipse with the MyRecord constructor that says:" The implicit super constructor Record() is undefined. Must explicity invoke another constructor". I tried super() but I get the same error. Can anyone please tell me what I am doing wrong? It seems to me that I am misunderstanding something about how abstract classes work.

    Because you defined a ctor that takes args, the implicit one that takes no args--super()--is no longer implicitly supplied. You have to either put a no-arg ctor into the parent class, or call the one that you already have.
    public Record(byte[] bytes) { }; //Should this be an empty constructor?
    public abstract byte[] getStorageFormat();
    }No. You don't want a ctor that takes args and does nothing. If you're taking that arg, then you should use it to initialize the state of the object.
    Here are the rules for constructors--"ctors" because I'm lazy. Also, because I'm lazy, "super(...)" and "this(...)" mean any super or this call, regardless of how many args it takes, including those that take no args.
    1) Every class has at least one ctor.
    1.1) If you do not define an explicit constructor for your class, the compiler provides a implicit constructor that takes no args and simply calls super().
    1.2) If you do define one or more explicit constructors, regardless of whether they take args, then the compiler no longer provides the implicit no-arg ctor. In this case, you must explicitly define a
    public MyClass() {...}
    if you want one.
    1.3) Constructors are not inherited.
    2) The first statement in the body of any ctor is either a call to a superclass ctor
    super(...)
    or a call to another ctor of this class
    this(...)
    2.1) If you do not explicitly put a call to super(...) or this(...) as the first statement in a ctor that you define, then the compiler implicitly inserts a call to super's no-arg ctor
    super()
    as the first call. The implicitly called ctor is always super's no-arg ctor, regardless of whether the currently running ctor takes args.
    2.2) There is always exactly one call to either super(...) or this(...) in each constructor, and it is always the first call. You can't put in more than one, and if you put one in, the compiler's implicitly provided one is removed.

  • Snapshop into a file

    Hello, I would like to know how can I save the snapshop that I take (MMAPI in MIDP 2.0) into a file and then I can use it like an icon
    thanks

    Hi,
    getSnapshot(..) returns a byte array, so you're able to create a new Image object immediately bu using that byte array, see Image.createImage(byte[ ], int, int).
    However, when you would like to store this snapshot as an file things get a little more complicated.
    Have you tried the setRecord(int recordId, byte[] newData, int offset, int numBytes) method in the RecordStore (RMS)? Looks like that it should be possible to add the byte array as a new record in the RMS. Okay, the snapshot will then not be available as a separate file object...
    There's also a possibility by using the 'Connector.open("file://<<<drive>>>/<<<local folder>>>")' method, but then it requires that your device manufacturer's implementation allows MIDlets to access its filesystem and to create new files... You will probably run into further Java security problems and annoying user dialogs (grant access to certain drives or folders, etc.).
    I suggest to look at the RMS part, unless you really would like to store the image as a separate (and accessible) file.
    Good luck!

  • The Levels bar into the red after normalization

    Sorry if this is a daft question, I am new to home recording and need to submit my audio via specific guidelines.  I'm trying to get into audiobook production.  I have a strong theatrical background but i don't know much about mastering audio so this has been challenging...
    In the raw file, the levels were primarily in green, occasionally in yellow.
    I used "match volume" to get my RMS to a certain level.  Then I used a limiter to set to -3 db.
    Now the file goes into the red.  According to Amplitude statistics.  there are 0 "possibly clipped samples" so why then do the levels keep going into Red?  I thought that was indicative of clipping?
    That's my first question, my second is does anyone know of any basic audio mastering classes for voiceover using Adobe Audition?  Less about how to edit audio, more about anatomy of audio files and the meaning of each of these parameters and how they relate to one another. 

    Thanks for your response.  I probably did a terrible job of explaining.
    I did originally try the "normalize" option and then the limiter but my RMS stats were too high to submit the audio book. They recommend normalizing peaks at -6db,  I found this video which states that you can normalize via RMS levels by match volume:  How to Normalize Audio Peak and RMS in Adobe Audition CS 5.5 Tutorial - Normalization - YouTube which I thought would at least bring that RMS number down so I was within their required range.  It did so all my amplitude specs meet their specs now but I'm just a little perplexed by the red in the level bar.
    This is all very new to me and I need to educated myself.  I don't even really understand the difference between normalization and compression and why one is favored over the other.  This is all really kind of over my head.  I think I can learn it but I need someone to explain it to my in layman's terms.
    When I do a raw recording, my Total RMS is always way over the recommended RMS the audiobook production company suggests a pre-mastered file should have.  Lowering  the gain makes the peak amplitude too low. That should be at -12 max while the RMS should be no greater than -28.  RMS is around -40.  So in a sorta related question, while recording, how do i lower my RMS without killing the peak amplitude. 

  • Reading contents of another (windows native) application

    Hi everyone!
    I would like to read some contents from another application, native to Windows, with my Java app.
    I have found the Jawin project (http://jawinproject.sourceforge.net/), but I have no idea how to find out the CLSID of the native application, which I need for creating a COM object handler... (through Jawin's DispatchPtr) ... if I understand this.
    Does anyone know how to do that, maybe?
    I would much appreciate it if someone could point me in the right direction or provide some code samples - either in Jawin or in some other way. Thank you for your help.
    Best regards,
    David

    Hi,
    The idea of my application is exactly the same that Kiran has mentioned in the 'Aim' of her post.
    i.e
    1 reading from a text file,
    2 parsing the contents,
    3 converting it into byte-array and
    4. adding these as records to an RMS record store.
    Ive been quiet successful in implementing these four steps. However, i face a problem now.
    Problem:
    So far the size of the text file was small i.e around 6 Kb and the app ran as expected.
    But now i need to read a much bigger file of around 50 kb.
    Bcoz the file size is huge, i have tried reading the file in chunks (i.e using delimiters in the file, reading small amounts of data via InputStream and storing in rms....)
    However, the whole file is being loaded at a strech and i get an OutOfMemoryException :(.
    Am i right when i say getResourceAsStream() loads the entire file in memory?? Is there no way for reading a huge .txt file in chunks without loading the entire file in memory?
    Kindly help.
    We gotta get thru! :)
    Smita.

  • Slow loading appliaction

    Hola! Wich r the parameters or factors that makes fast or slow an application when is being open? The size of teh MIdp2.0 application, the creation (execution of teh constructor of teh classes)+ load info stored in the RMS........ something more? my application is taking 23 seocnd to be open , is 124K in that moment.........
    Thanks

    Hi,
    23 seconds is not that bad. I've seen start up times that were worse than that. However, all your mentioned 'parameters' will be causing this need of 23 seconds. And of course, the mentioned CPU speed. However, you can't do anything about that last one...
    Improving speed is a huge task. There are some things to remember:
    - Reduce the number of different records in the RMS (this might require a smart solution);
    - Avoid large images;
    - Avoid redundant OO-like methods: return to the old way of programming, just inline methods (aaah, this really looks so ugly, however: it matters...);
    - Try to get rid of redundant OO-like classes, because they will take ROM and also take loading time (classloading). Again: this will look really ugly: inlining of methods and large sequences.
    - Be careful with String operations, because they're an attack on the heapsize and an attack on the speed.
    Like all articles and books covering optimalisation, I must say: don't do it. Only do it when it's really necessary and when you've got the time for it. Wasn't there something mentioned in a book about a 80/20 rule about optimalisation? 20% of your code is used frequently, so that's the only part the might be suitable for optimalisation...
    Start with simple things like: "is this object really necessary?" Improve for-loops
    Don't use things like this:
    for (int i = 0; i < someArray.length; i++)
    }but try this (yes, there's an extra declaration, but it's still faster):
    int size = someArray.length;
    for (int i = 0; i < size; i++)
    }or even consult this:
    int size = someArray.length;
    for (int i = size - 1; i > 0; i--)
    }(substraction is a little bit faster than addition).
    And of course: try to avoid declarations inside for-loops, but move them outside the loop.
    Good luck!!

  • Accessing resources on device

    How would you access resources, such as media (mp3) stored on the device (flash card), list available such resources, download and save (rather than to the record store) etc.?

    A little summery for future ref:
    Intro
    "The FileConnection API [JSR-075] gives access to file systems and support for file-oriented operations. The API assumes the existence of a file system in the device that can be located, for example, in removable memory cards, flash memory, or other types of persistent storage. This API is not meant to be a replacement for the Record Management System (RMS) but rather a complement to it allowing MIDlets to interact with native applications. For example, a MIDlet could access and manipulate images previously captured by a native application using a built-in digital camera. Those images are commonly stored in the device�s memory and with the FileConnection API they are made accessible to CLDC/CDC1 applications."
    "The API is very simple containing just one class, two interfaces, and two exceptions. The most important part is the FileConnection interface, which extends the Connection interface and gives access to directories and individual files. Implementations of FileConnection are created using the Connector.open() method. The argument of the open() method is a URL with the format file://<host>/<path>, as defined in RFC 1738 [RFC 1738] and RFC 2396 [RFC 2396], where host is normally left empty and path starts with the root of the file system down to a particular file or directory. An example of a typical file URL in a Symbian device looks like the following: file:///C:/Nokia/Images/Image(001).jpg The roots of the file system are device-specific and they don�t necessarily correspond to physical memory units since they are logically defined by the device�s operating system."
    "Since the FileConnection API is an optional extension, a system property has been added to indicate the API�s presence. The microedition.io.file.FileConnection.version system property contains the implemented version of the API. Currently this property should have the value 1.0 to indicate the current status of the API or null if the API is not present."
    supporting environments:
    IBM's J9, PalmOS 5, Windows Mobile 2003.
    Some mobile phones supporting FileConnection are listed here: http://www.benhui.net/modules.php?name=Midp2Phones
    Links:
    http://www-128.ibm.com/developerworks/library/j-pda-op/
    http://jcp.org/aboutJava/communityprocess/final/jsr075/index.html
    http://itpapers.techrepublic.com/abstract.aspx?docid=104503
    http://forum.java.sun.com/thread.jspa?threadID=524143&tstart=210

  • J2ME - RMS - Record Enumeration - compilation problem

    Hi,
    Im trying to create RMS with Record Enumeration. Able to open a recordstore & write a record in it; while reading the record with record enumeration, im assigning the recordstore object to enumeration. Here compilation problem occurs. Im attaching the code which im working. Please help me to solve this issue.
    import javax.microedition.midlet.*;
    import javax.microedition.rms.*;
    import javax.microedition.lcdui.*;
    import java.io.*;
    public class RecordEnumeration extends MIDlet implements CommandListener
         private Display display;
         private Alert alert;
         private Form form;
         private Command cmdOpen, cmdWrite, cmdRead, cmdClose, cmdDelete, cmdExit;
         private RecordStore rs = null;
         private RecordEnumeration re = null;
         public RecordEnumeration()
              display = Display.getDisplay(this);
              cmdOpen = new Command("Open", Command.SCREEN, 1);
              cmdWrite = new Command("Write", Command.SCREEN, 1);
              cmdRead = new Command("Read", Command.SCREEN, 1);
              cmdClose = new Command("Close", Command.SCREEN, 1);
              cmdDelete = new Command("Delete", Command.SCREEN, 1);
              cmdExit = new Command("Exit", Command.SCREEN, 1);
              form = new Form("RecordEnumeration");
              form.addCommand(cmdOpen);
              form.addCommand(cmdWrite);
              form.addCommand(cmdRead);
              form.addCommand(cmdClose);
              form.addCommand(cmdDelete);
              form.addCommand(cmdExit);
              form.setCommandListener(this);
         public void startApp()
              display.setCurrent(form);
         public void pauseApp()
         public void destroyApp(boolean unconditional)
         public void commandAction(Command cmd, Displayable displayable)
              if(cmd == cmdExit)
                   destroyApp(true);
                   notifyDestroyed();
              else if(cmd == cmdOpen)
                   try
                        rs = RecordStore.openRecordStore("RecordEnumeration", true);
                        System.out.println("Opening Record");
                   catch(Exception err)
                        alert = new Alert("Err Opening", err.toString(), null, AlertType.WARNING);
                        alert.setTimeout(Alert.FOREVER);
                        display.setCurrent(alert);
              else if(cmd == cmdWrite)
                   try
                        String StringOutput[] = {"First Record", "Second Record", "Third Record"};
                        for (int x = 0; x < 3; x++)
                             byte[] byteOutputData = StringOutput[x].getBytes();
                             rs.addRecord(byteOutputData, 0, byteOutputData.length);
                             System.out.println("Record "+ x +" Added");
                   catch (Exception err)
                        alert = new Alert("Err Writing", err.toString(), null, AlertType.WARNING);
                        alert.setTimeout(Alert.FOREVER);
                        display.setCurrent(alert);
              else if(cmd == cmdRead)
                   try
                        StringBuffer buffer = new StringBuffer();
                        re = rs.enumerateRecords (null, null, false);
                        while (re.hasNextElement())
                             buffer.append(new String(re.nextRecord()));
                             buffer.append("\n");
                        alert = new Alert("Enumeration", buffer.toString(), null, AlertType.WARNING);
                        alert.setTimeout(Alert.FOREVER);
                        display.setCurrent(alert);
                        System.out.println("Reading");
                   catch(Exception err)
                        alert = new Alert("Err Reading", err.toString(), null, AlertType.WARNING);
                        alert.setTimeout(Alert.FOREVER);
                        display.setCurrent(alert);
              else if(cmd == cmdClose)
                   try
                        rs.closeRecordStore();
                        System.out.println("Closed");
                   catch(Exception err)
                        alert = new Alert("Err Closing", err.toString(), null, AlertType.WARNING);
                        alert.setTimeout(Alert.FOREVER);
                        display.setCurrent(alert);
              else if(cmd == cmdDelete)
                   try
                        RecordStore.deleteRecordStore("RecordEnumeration");
                        re.destroy();
                        System.out.println("Deleted");
                   catch(Exception err)
                        alert = new Alert("Err Deleting", err.toString(), null, AlertType.WARNING);
                        alert.setTimeout(Alert.FOREVER);
                        display.setCurrent(alert);
    These are the error which im getting while compiling in WTK.
    C:\WTK2.5.1\apps\WritingMixedData\src\RecordEnumeration.java:60: incompatible types
    found : javax.microedition.rms.RecordEnumeration
    required: RecordEnumeration
                        RecordEnumeration re = rs.enumerateRecords(null,null,false);
                        ^
    C:\WTK2.5.1\apps\WritingMixedData\src\RecordEnumeration.java:99: cannot find symbol
    symbol : method hasNextElement()
    location: class RecordEnumeration
                        while (re.hasNextElement())
                        ^
    C:\WTK2.5.1\apps\WritingMixedData\src\RecordEnumeration.java:101: cannot find symbol
    symbol : method nextRecord()
    location: class RecordEnumeration
                             buffer.append(new String(re.nextRecord()));
                             ^
    C:\WTK2.5.1\apps\WritingMixedData\src\RecordEnumeration.java:136: cannot find symbol
    symbol : method destroy()
    location: class RecordEnumeration
                        re.destroy();
                        ^
    4 errors
    Advices are welcome. Thanks in advance.
    -Singu

    Hi Guys,
    J2ME TECHNOLOGIES
    I created a record store and inserted record date "random" into it using the following code.
    RecordStore rs = null;
    try {
    rs = RecordStore.openRecordStore( "myrs",true);
    //rs = RecordStore.openRecordStore( "myrs",false );
    rs.setMode(1,true);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    DataOutputStream dos = new DataOutputStream(baos);
    try{dos.writeUTF("random");}catch(Exception e){}
    byte[] b = baos.toByteArray();
    rs.addRecord(b, 0, b.length);
    }catch(Exception e){}
    I executed this MIDLET TO INSERT.
    I closed the application and tried to look for the physical db file inside my application folder where i couldnt find it.
    Then i tried to read the data from RECORD STORE myrs using the the same MIDlet by editing the aboe code as follows
    RecordStore rs = null;
    try {
    rs = RecordStore.openRecordStore( "myrs",false);
    byte[] recData = new byte[10];
    ByteArrayInputStream bais = new ByteArrayInputStream(recData);
    DataInputStream dis = new
    DataInputStream(bais);
    rs.getRecord(1, recData, 0);
    try{System.out.println("UTF: " + dis.readUTF());}catch(Exception e){}
    System.out.println("--------------------");
    } catch( RecordStoreException e ){// couldn't open it or create it
    System.out.println("data base creation error"+e);
    But when i executed it the error occured
    microedition.rms.RecordStoreNotFoundException: cannot find record store file
    My question in my first code ive created the data store and inserted the values into my recordstore myrs
    Then when i edit the code for creation into reading from the record store why the error occurs.Does the Midlet store the record store Temporarirly ONLY till the MIDLET LIFECYCLE.
    IF SO what is the method and code to store the RECORD STORE PERMANENTLLY EVEN AFTER THE MIDLET EXECUTION QUITS.
    ///////////////////////kARTHEE

  • RMS -- Getting the RecordId of the Current Record

    Hello, I need to get the current record Id from recordStore so I can update a count field. Here is the code that updates the count field.
    // member vars to hold RMS stuff
    private RecordStore rs;
    private RecordEnumeration re;
    private ByteArrayOutputStream os;
    // Constructor allocates RMS vars
    public Ctor ( String sRmsFilename ) throws Exception {
    rs = RecordStore.openRecordStore ( sRmsFilename, false );
    re = rs.enumerateRecords ( null, null, true );
    re.keepUpdated ( true );
    os = new ByteArrayOutputStream ();
    ////// METHOD REQUIRING CURRENT RECORD ID
    private void updateDBCount ( int count ) throws Exception {
    DataOutputStream dos = new DataOutputStream ( os ) ;
    dos.writeInt ( count );
    *int currentRecordId = {color:#008080}getCurrentRecordId {color}();*
    byte[] b = os.toByteArray ();
    os.reset ();
    rs.setRecord ( currentRecordId, b, 0, b.length );
    This is the code that I use to retrieve the recordId of the current record;
    ////////// CODE TO RETRIEVE CURENT RECORD ID
    private int getCurrentRecordId () throws Exception {
    *if ( re.{color:#0000ff}hasPreviousElement{color} () ) {*
    *re.{color:#0000ff}previousRecordId{color} ();*
    *return re.{color:#0000ff}nextRecordId{color} ();*
    *else {*
    *re.{color:#0000ff}nextRecordId{color} ();*
    *return re.{color:#0000ff}previousRecordId{color} ();*
    This is how getCurrentRecordId () is suppose to work, using RecordEnumeration. If there is a previous record then advance backwards to previous record. Now advance forward to next record and this should been the current record Id and so it is return. However, if there is no previous record then advance forward to next record. Now advanced backward to previous record and this should been the current record Id and so it is return.
    Well, does anyone see a problem with this code? If so please let me know and, of course, as always any suggestions are very welcome!
    Note: The reason I chose to use RecordEnumeration.nextRecordId () / previousRecordId () methods is because I figured it is run fast and less resources would be consumed than if actual records were retrieved using RecordEnumeration.nextRecord () / previousRecord ()methods.
    Thanks!

    {color:#000080}I see a problem if the RecordStore has no records, or only one record. This is what I might do (untested)private int getCurrentRecordId () throws Exception
        if ( re.numRecords() == 0 )
            // maybe you want to add a record
            // or maybe throw a new Exception
            // or just return -1 or 0 and
            // let the calling routine handle that
            return -1;
        } else if ( re.numRecords() ==1 )
            return 1;
        } else if ( re.hasPreviousElement () )
            re.previousRecordId ();
            return re.nextRecordId ();
        } else
            re.nextRecordId ();
            return re.previousRecordId ();
    }Regarding running fast, the documentation for javax.microedition.rms.RecordEnumeration says{color}
    keepUpdated - if true, the enumerator will keep its enumeration current with any changes in the records of the record store. Use with caution as there are possible performance consequences.{color:#000080}
    Actually, since you do not have a filter or comparator, it would probably be more efficient to keep track of the current record with a int instance field. But that's your choice.
    Cheers, Darryl{color}

  • RMS Delete Record

    Hi,
    I have a RecordStore that store bytes of images. In this Record Store could be more than one images. When I delete one of this record it can happens that the avalaible size of the Record Store is the same of that before of delete although the record is deleted (the number of record in the Record Store is more small than 1) . This situation is not regullary because other times this doesn't happen: when I delete a record (with rs.deleteRecord(i)) the avalaible size grow up. Do you know bugs o particullary situation of RMS? Can you help me?

    Hi,
    When you delete a record youdont actually delete it but you set the contents for that record Id as null.
    i.e. The size of your recordstore will be the maximum number of records it ever held.
    Also if you delete a record, the records following will not be shifted up.
    i.e. if for record id
    1) Birds
    2) Bees
    3) Honey
    are the records in my recordstore then rs.deleteRecord(2) results in the following structure
    1) Birds
    2) <null>
    3) Honey
    Personally I use another recordstore to manage my data stores. However the correct method i believe is to use record enumeration. Cant help you with that. Shmoove is probably the best person to ask.

Maybe you are looking for

  • Finding rotation of degrees of text

    I have found vertical flow of text by using PDWordGetAttrEx(thisWord, 0) & WXE_VERTICAL_FLOW,if(PDWordGetAttrEx(thisWord, 0) & WXE_ROTATED) Please help me to find out the degree of rotation of text in pdf,i want to exact degrees.

  • Help - AutoCAD to PDF

    Is there any java free api to convert AutoCAD formats (DWG or DXF) into PDF? Thanks

  • When i turn my ipod on it said use itunes to restore......

    when i turn my ipod on it said use itunes to restore. SO i downloaded the new itunes (7.2 i think) and when i pluged ipod in it said ipod in recovery mode restore before use in itunes for sumthin like that... so i did that and at the end it said erro

  • Battery went from 100% to 0% and won't charge :C

    Hi guys i need some help. About 15min ago i was reading an article on a website when the screen 'blinked' it turned off going completly black then turned on again. Then i noticed that it said i had 0% battery but i have my MacBook Pro is plugged in r

  • Kindly check the query

    The following fields are to be taken from the tables as mentioned below: Meter Reading Unit (MRU)       – (EANLH-ABLEINH) MRU Description           – (TE422-TERMTEXT) Meter Reading Center           – (TE422-ABL_Z) Meter Reading Center Description – (