Jump to content
  • Advertisement
Sign in to follow this  
LinkOfTime

[java] Need help using the RecordStore class in J2ME programming

This topic is 4329 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Help!!! I have been stuck with this class for over a week now. I tried using it to save some data of my game in the mobile phone's memory but I keep getting exceptions or it doesn't save the data. I also tried looking for examples over the internet but, when I try to run those examples I get the same exceptions... Here is my code:
	static void saveGame()
	{
		byte SavedData[]=GameData.MyNoki.Name.getBytes();
		try
		{
			RecordStore SavedRecord = RecordStore.openRecordStore("TheNokiesSave",true);
			SavedRecord.addRecord(SavedData,0,GameData.MyNoki.Name.length());
			SavedRecord.closeRecordStore();
		}
		catch (Exception e)
		{
			System.out.println(e);
		}
	}

Please help me fix the method so it would work... Lots of thanks in advance to all the helpers :) P.S: Here is the explanation page of the class in Sun's Java API: http://java.sun.com/javame/reference/apis/jsr118/

Share this post


Link to post
Share on other sites
Advertisement
Care to share what the exceptions are that you are getting?

Also how do you know the data isn't saved, are you sure you are reading it correctly?

There is a very useful free online book that has a chapter about RMS. The code from that book works for me. Book

You could also try J2ME Forums they are pretty active and if you search you can probably find some example code there.

Share this post


Link to post
Share on other sites
One thing that I see you are doing wrong is that you are creating a new record every time you save the game. You need to test to see if the RecordStore is already there, and if it is you should only update the existing record (or at least delete the old record before you add the new one).

I don't think this has much to do with the problem you described though. On that I can only join Greig in asking what Exception are you getting?

shmoove

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!