I wrote application that is downloading some data from API, then parsing it and putting into SQlite Database. The application crashes after setting SimpleCursorAdapter into list view.
public Cursor getCursor(){
return mDb.query(PHOTO_TABLE,TABLE_FIELDS,null,null,null,null,null);
}
PhotoDataBase db=new PhotoDataBase(getApplicationContext());
db.open();
for(int i=0;i<photos.size();i++){
ContentValues value=new ContentValues();
value.put(PhotoDataBase.KEY_ROWID,i);
value.put(PhotoDataBase.TITLE,photos.get(i).mTitle);
value.put(PhotoDataBase.OWNER,photos.get(i).mOwner);
db.insertData(value);
}
Cursor cursor=db.getCursor();
adapter=new SimpleCursorAdapter(getApplicationContext(),android.R.layout.simple_list_item_1,cursor,
new String[]{PhotoDataBase.TITLE},
new int[]{android.R.id.text1},0);
listView.setAdapter(adapter);
db.close();
cursor.close();