×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Jun 2006
    Posts
    3

    RMS.db file size

    when we use methods like addrecord, deleterecord, setrecord of recordstore class
    in MIDP 2.0. , actual file size keep on increasing while using deleterecord , setrecord
    methods.

    any solution to control RMS file size... ?

  2. #2
    Super Contributor
    Join Date
    Nov 2003
    Location
    Bangalore , India
    Posts
    4,429

    Re: RMS.db file size

    Hi surana_ajay! Welcome to Nokia Discussion Boards!!

    Do you mean RMS size increasing while using deleteRecord?
    May be you should post the code for RecordStore operations so that some one here could give a try.

    Regards
    Gopal

  3. #3
    Registered User
    Join Date
    Jun 2006
    Posts
    3

    Re: RMS.db file size

    this code is test on the nokia 6600

    run the code on mobile , then add ,then update , chk file size by FEexplorer
    again update record , chk size
    delete rec , chk size


    import javax.microedition.lcdui.Command;
    import javax.microedition.lcdui.CommandListener;
    import javax.microedition.lcdui.Display;
    import javax.microedition.lcdui.Displayable;
    import javax.microedition.lcdui.Form;
    import javax.microedition.midlet.MIDlet;
    import javax.microedition.rms.RecordStore;
    import javax.microedition.rms.RecordStoreNotOpenException;

    class RMSNEW implements CommandListener
    {
    private static final String RMS_NAME = "RMSTEST11";
    byte byData [] ={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50};

    byte byUPData [] ={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50};

    private Form frmDisplay;
    private static Display displayUI;
    private Command cmdDelete;
    private Command cmdAdd;
    private Command cmdUpdate;
    private RecordStore rs;

    public void setDisplay(MIDlet midlet)
    {
    displayUI = Display.getDisplay(midlet);
    getForm();
    setDatabase();
    displayUI.setCurrent(frmDisplay);
    }

    public void setDatabase()
    {
    try
    {
    //if(isExist(RMS_NAME) == false)
    {
    createDatabase(RMS_NAME);
    }
    openDatabase(RMS_NAME);
    getRMSInformation();
    }
    catch(Exception e)
    {
    System.out.println("In create"+e);
    }
    }

    public Form getForm()
    {
    if(frmDisplay == null)
    {
    frmDisplay = new Form("RMSTEST");
    }
    return frmDisplay;
    }

    static String str,str1,str2;
    public void getRMSInformation()
    {
    try
    {
    frmDisplay = null;
    getForm();
    frmDisplay.append("NumRecords is ==");
    str =str.valueOf(getNumRecords());
    frmDisplay.append(str);
    frmDisplay.append("\n");
    frmDisplay.append("Size is ==");
    str1 =str1.valueOf(getSize());
    frmDisplay.append(str1);
    frmDisplay.append("\n");
    frmDisplay.append("SizeAvailable ==");
    str2 =str2.valueOf(getSizeAvailable());
    frmDisplay.append(str2);
    //frmDisplay.append("\n");
    //frmDisplay.append("Data "+(byData));
    frmDisplay.addCommand(getAddCommand());
    frmDisplay.addCommand(getDeleteCommand());
    frmDisplay.addCommand(getUpdateCommand());
    frmDisplay.setCommandListener(this);
    displayUI.setCurrent(frmDisplay);
    System.out.println("RMS getName()::"+getName());
    System.out.println("RMS getNumRecords()::"+getNumRecords());
    System.out.println("RMS getSize()::"+getSize());
    System.out.println("RMS getSizeAvailable()::"+getSizeAvailable());
    //System.out.println("Data::"+(byData));
    }
    catch(Exception e)
    {
    System.out.println("In the RMS INFO function"+e);
    }
    }


    public int getNumRecords() throws RecordStoreNotOpenException
    {
    return rs.getNumRecords();
    }

    public int getSize() throws RecordStoreNotOpenException
    {
    return rs.getSize();
    }

    public String getName() throws RecordStoreNotOpenException
    {
    return rs.getName();
    }

    public int getSizeAvailable() throws RecordStoreNotOpenException
    {
    return rs.getSizeAvailable();
    }

    public void createDatabase(String sDBName)throws Exception
    {
    try
    {
    rs = RecordStore.openRecordStore(sDBName,true);
    }
    catch(Exception e)
    {
    System.out.println("In create"+e);
    }
    }

    public void openDatabase(String sDBName)throws Exception
    {
    try
    {
    rs = RecordStore.openRecordStore(sDBName,true);
    }
    catch(Exception e)
    {
    System.out.println("In openDatabase"+e);
    }

    }


    public void addRecord(byte[] byData)
    {
    try
    {
    rs.addRecord(byData,0,byData.length);
    }
    catch(Exception e )
    {
    System.out.println("Exception In the upDate Record "+e);
    }
    }

    private void upDateRecord(byte[] byData)
    {
    try
    {

    int iIndex =rs.getNextRecordID()-1;
    rs.setRecord(iIndex,byUPData,0,byData.length);
    catch(Exception e )
    {
    System.out.println("Exception In the upDate Record "+e);
    }
    }

    private Command getAddCommand()
    {
    if (cmdAdd== null)
    {
    cmdAdd = new Command("ADD",javax.microedition.lcdui.Command.ITEM, 1);
    }
    return cmdAdd;
    }

    private Command getDeleteCommand()
    {
    if (cmdDelete== null)
    {
    cmdDelete = new Command("DELETE",javax.microedition.lcdui.Command.ITEM, 1);
    }
    return cmdDelete;
    }

    private Command getUpdateCommand()
    {
    if (cmdUpdate== null)
    {
    cmdUpdate= new Command("UPDATE",javax.microedition.lcdui.Command.ITEM, 1);
    }
    return cmdUpdate;
    }

    public void commandAction(Command command, Displayable arg)
    {
    if(command == cmdAdd)
    {
    addRecord(byData);
    getRMSInformation();
    }
    else if(command == cmdDelete)
    {
    //displayDeleteInformation();
    try{
    rs.deleteRecord(1);
    }
    catch (Exception e) {
    }
    getRMSInformation();
    }
    else if(command == cmdUpdate)
    {
    upDateRecord(byUPData);
    getRMSInformation();
    }
    }
    }

Similar Threads

  1. 3GP File size
    By zi123 in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2005-11-17, 12:26
  2. strange behavior on sending jar file via WAP for different mobile network
    By thone in forum Digital Rights Management & Content Downloading
    Replies: 2
    Last Post: 2005-10-28, 07:53
  3. Replies: 0
    Last Post: 2005-10-27, 20:51
  4. 30 KB, 50 KB MMS File Size Limits???
    By rmsj in forum General Messaging
    Replies: 2
    Last Post: 1970-01-01, 02:00
  5. So the MMS File SIze is the Size of What?
    By rmsj in forum General Messaging
    Replies: 1
    Last Post: 1970-01-01, 02:00

Posting Permissions

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