×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Regular Contributor
    Join Date
    Sep 2009
    Posts
    84

    Enumeration & Deteling records in an RMS

    insert this in the startApp method.
    Code:
    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.

  2. #2
    Regular Contributor
    Join Date
    Sep 2009
    Posts
    84

    Re: Enumeration & Deteling records in an RMS

    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.

    {code}
    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());
    }
    }
    {code}

    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
    Last edited by WildHeart; 2010-04-29 at 00:39.

Similar Threads

  1. error PRJ0019 error while creating sis file
    By mrshine in forum Symbian C++
    Replies: 3
    Last Post: 2008-10-17, 17:16
  2. RMS record sizes.
    By earamsey in forum Mobile Java General
    Replies: 1
    Last Post: 2007-10-18, 13:51
  3. RMS questions -- updating and deleting records
    By earamsey in forum Mobile Java General
    Replies: 1
    Last Post: 2007-09-18, 18:16
  4. RMS limits - max records per recordstore
    By conos in forum Mobile Java General
    Replies: 3
    Last Post: 2007-02-28, 10:15
  5. RMS records - where are they stored in 7650 emulator?
    By Kiigan in forum Mobile Java Tools & SDKs
    Replies: 5
    Last Post: 2003-04-16, 06:09

Posting Permissions

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