Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a database adapter,layout files for populating a listview from a database table.
I dont see any error in the code but get a message that 'apps has stopped working'.
However I feel that the problem lies at the line that raises the 'simpleCursorAdapter..'
If I comment that line and run the code there is NO error like 'apps stopped working'.
Can anyone help me out so that I can raise the listview from Sqlite database.
Java
Cursor cursor= vivzHelper.getAllRows();
String [] from=new String[]{vivzHelper.NAME};
int[] to=new int[]{ R.id.item_name};
SimpleCursorAdapter dataAdapter;
dataAdapter=new SimpleCursorAdapter(this,R.layout.item_layout, cursor, from, to,0);
ListView listView = (ListView) findViewById(R.id.listView1);
listView.setAdapter(dataAdapter);

Code at DBhelper:
Java
Cursor getAllRows( ){
    db = helper.getWritableDatabase();
    Cursor mCursor=null;
    String [] columns={VivzHelper.NAME};
    mCursor= db.query(VivzHelper.TABLE_NAME,columns,null,null,null,null,null);
    if (mCursor!=null) {
        mCursor.moveToFirst();
    }
    return mCursor;
}
Posted
Updated 17-Mar-15 21:58pm
v2

1 solution

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