Click here to Skip to main content
15,901,035 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
hi,

the program i am creating has two buttons, one to add records and one to view all added records.
the records add succesfully, but records cannot be viewed. i dont understand what ive done wrong:
Java
public String getData() {
    // TODO Auto-generated method stub
    String[] columns = new String[]{KEY_ROWID, KEY_TYPE, KEY_MODULENAME, KEY_ASSWEIGHTING, KEY_ISSUEDATE,
                                      KEY_DUEDATE, KEY_NOTES};
    //Read information from columns
    Cursor c = ourDatabase.query(DATABASE_TABLE, columns, null, null, null, null, null);
    String result = "";

    int iRow = c.getColumnIndex(KEY_ROWID);
    int iType = c.getColumnIndex(KEY_TYPE);
    int iName = c.getColumnIndex(KEY_MODULENAME);
    int iWeighting = c.getColumnIndex(KEY_ASSWEIGHTING);
    int iIssue = c.getColumnIndex(KEY_ISSUEDATE);
    int iDue= c.getColumnIndex(KEY_DUEDATE);
    int iNotes = c.getColumnIndex(KEY_NOTES);

    //read entries until cursor is at the end of the last entry

    for (c.moveToFirst();!c.isAfterLast(); c.moveToNext()) {
        //set result to information being read
        result = result +c.getString(iRow) + " " + c.getString(iType) + " " +
                c.getString(iName) + " " + c.getString(iWeighting) + " " + c.getString(iIssue) + " "
                + c.getString(iDue) + " " + c.getString(iNotes) + "\n";
    }
    return result;

}
Posted
Comments
Sergey Alexandrovich Kryukov 18-May-13 22:10pm    
Are you a developer or not? If you are, there is no "crash". You would be able to observe exception and provide comprehensive exception information: type, message, in what line, its stack, etc.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900