Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
In my android apps project after inserting rows I intend to get all data for display.
I use cursor for this. What happens is that on click of the button I get an error in the device stating that 'apps has stopped'. There is no error in the code.
The following is the code:

Java
public String getAllData() {
      SQLiteDatabase db = helper.getWritableDatabase();
        String[] columns = {helper.COLUMN_ID, helper.COLUMN_NAME};
        Cursor cursor = db.query(helper.TABLE_ACCOUNTHEADS, columns, null, null, null, null, null);
        StringBuffer buffer = new StringBuffer();

        while(cursor.moveToNext())
        {
            int cid = cursor.getInt(0);
            String accountname = cursor.getString(1);
            buffer.append(cid + " " + accountname + "\n");

        }
        return buffer.toString();
Posted
Updated 9-Mar-15 18:45pm
v2
Comments
Xiao Ling 10-Mar-15 2:31am    
Could you please post your crash log?
S.Rajendran from Coimbatore 10-Mar-15 2:34am    
is that event log?
Xiao Ling 10-Mar-15 2:40am    
Check DDMS, and dump error info. For example, NullPointerException.
S.Rajendran from Coimbatore 10-Mar-15 2:48am    
After running the app the event log:
12:17:31 PM Gradle build finished in 8 sec
12:17:31 PM Session 'app1': running
S.Rajendran from Coimbatore 10-Mar-15 2:49am    
in ddms how to find dump error

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