Skip to main content

Please Help In J2me Http and Rms code

3 replies [Last post]
timonjue
Offline
Joined: 2006-12-15

I have a problem saving data in an rms file.
Here is the code
public void AddNewUser(String record)
{
try
{
rs=RecordStore.openRecordStore("RsUser", true,RecordStore.AUTHMODE_ANY , true);
}
catch(RecordStoreException ex)
{
System.out.println(ex);
ex.printStackTrace();
}
try
{
byte [] Bytes=record.getBytes();
rs.addRecord(Bytes,0,Bytes.length);
int count=rs.getNumRecords();
}
catch(RecordStoreNotOpenException ex)
{
System.out.println(ex);
ex.printStackTrace();
}
catch(RecordStoreException ex)
{
System.out.println(ex);
ex.printStackTrace();
}

}

When i invoke the method rs.getnumrecords it returns zero though at saving the method does not throw any exception

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
sfitzjava
Offline
Joined: 2003-06-15

what is this on? WTK?
Have you set the data size in the Jad?

timonjue
Offline
Joined: 2006-12-15

How do i set the data size in the jad. The method above is just for adding a new user it accepts the string as the parameter and then saves it in the RMS file.Thats what at least I gathered from the net. The problem is there is no record saved.

sfitzjava
Offline
Joined: 2003-06-15

I do not appreciate personal emails with questions. My job is not to teach noobies how to program. There are plenty of books and online material to teach you these things. I donate some of my time to help serious developers with serious issues and conflicts in the javame programming world.
Here are some links that might help you learn about RMS
http://mobilepit.com/05/an-excellent-javame-rms-recordstore-tutorial.html
http://developers.sun.com/mobility/midp/articles/databaserms/
http://www.j2meforums.com/wiki/index.php/Tutorials

Having said that, edit your JAD file and put an entry such as the following line:
MIDlet-Data-Size: 3000

This is a 3000byte allocation for a RMS store.
Also try just opening the RMS for your application with the base call:
RecordStore.open("RsUser", true);
Since I have no idea what tools you are using there may be some bug with that call in the emulator you are using.

Post your HTTP source and question in the forums if you want it answered.