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.
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:
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;
}