tags:

views:

70

answers:

1

I have this code. And basically this returns the correct data without the town qualities. When I add the town qualities the method returns nothing, not even the orginal data that it has been and I dont know why. Can anyone see a problem?

 protected void listRecords() {
    mListForm.deleteAll(); // clear the form
    try {
        RecordStore rs = RecordStore.openRecordStore("Details", true);
        RecordEnumeration re = rs.enumerateRecords(null, new RecordSorter(), false);
        while (re.hasNextElement()) {
            byte [] recordBuffer = re.nextRecord();
            String record = new String(recordBuffer);

            // extract the name and the age from the record

            int endOfName = record.indexOf(";");
            int endOfDesc = record.indexOf(";" , endOfName + 1);
            int endOfTown = record.indexOf (";", endOfDesc + 1);

            String name = record.substring(0, endOfName);
            String desc = record.substring(endOfName + 1, endOfDesc);
            String town = record.substring(endOfDesc +1, endOfTown);

            mListForm.append(name + " aged: "+ desc + "   " + town);
        }
        rs.closeRecordStore();
    }
    catch(Exception e){
        mAlertConfirmDetailsSaved.setString("Couldn't read details");
        System.err.println("Error accessing database");
    }
    mDisplay.setCurrent(mListForm);

}
A: 

Have you tried running it in the debugger? Is the exception happening? Are the three semicolons present in the record? Is there a limit on mDisplay's string size? When setCurrent is called, is the mListForm correct?

In other words, what have you done so far and where is it definitely right, and where does it become wrong?

Lou Franco
How is this the correct answer? It's a good answer but it just asks for more details on the problem. I think this question should be deleted or closed if there isn't conversation on the problem.
Fostah