Sign in to follow this  
NightMonkey

Mobile Phone - Record Stores

Recommended Posts

NightMonkey    122
Hi, im writing a function to save my game options to a record store however it keeps throwing a RecordStoreException error. Any Ideas what im doing wrong? code: public void saveOptions() { try { RecordStore r = RecordStore.openRecordStore("Options",true); byte[] temp = new byte[2]; if (VibrationOption) temp[0] = 1; else temp[0] = 0; if (SoundOption) temp[1] = 1; else temp[1] = 0; r.setRecord(1,temp,0,2); r.closeRecordStore(); } Catch (RecordStoreException e) { System.out.println("Error Saving Options");} }

Share this post


Link to post
Share on other sites
shmoove    821
The RecordStoreException is the superclass of a bunch of more specific exceptions. Instead of just printing an error message, use e.printStackTrace() to see what specific kind of Exception it is and what method is throwing it. My guess is that you're using setRecord() to try to update a record that doesn't exist (because you haven't addRecord()ed it yet) and getting an InvalidRecordIDException. In that case having:

try {
r.setRecord(1,temp,0,2);
}
catch (InvalidRecordIDException irie) {
r.addRecord(temp,0,2);
}

will fix it.

shmoove

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this