So, im trying to write a program where i can create tasks, show their names and dates in listview and just simply edit them after clicking on them in listview
Im having some problems with populating. I need to use SimpleCursorAdapter for this program(as an assignment from my university)
This is my populate function which is inside my MainActivity
private void populate(){
Cursor cursor = myDb.getAllRows();
String[] backDB = new String[] {DBAdapter.COLUMN_NAME, DBAdapter.COLUMN_DATE};
int[] toView = new int[] {R.id.textViewName, R.id.textViewDate};
SimpleCursorAdapter myCursor;
myCursor = new SimpleCursorAdapter(getBaseContext(), R.layout.row_layout, cursor, backDB,toView, 0);
ListView myList = (ListView) findViewById(R.id.listViewTasks);
myList.setAdapter(myCursor);
}
i am thinking it might be related to sql database, especially getAllRows function because in logcat i can see there is a problem with the line:
myCursor = new SimpleCursorAdapter(getBaseContext(), R.layout.row_layout, cursor, backDB,toView, 0);
So, here is my getAllRows function
public Cursor getAllRows() {
String query = "SELECT * FROM " + TABLE_NAME;
Cursor c = db.rawQuery(query, null);
c.moveToFirst();
return c;
}
My program just crashes and keeps crashing btw.