• Advertisement
Sign in to follow this  

Mobile Phone - Record Stores

This topic is 4649 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

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
Advertisement
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
Sign in to follow this  

  • Advertisement