每次尝试运行此方法时,我的程序都会崩溃:
private void populateListView() {
Cursor cursor = myDB.getAllRows();
startManagingCursor(cursor);
String[] from = new String[] {ProductContract.ProductEntry.INPUT, ProductContract.ProductEntry.DATE};
int[] to = new int[] {R.id.t_input, R.id.t_date};
SimpleCursorAdapter myCursorAdapter = new SimpleCursorAdapter(getBaseContext(), R.layout.display_row, cursor, from, to, 0);
ListView myList = (ListView) findViewById(R.id.display_listview);
myList.setAdapter(myCursorAdapter);
}
这是我的getAllRows方法:
public Cursor getAllRows() {
SQLiteDatabase db = this.getWritableDatabase();
Cursor c = db.query(true, ProductContract.ProductEntry.TABLE_NAME, ProductContract.ProductEntry.ALL_KEYS,
null, null, null, null, null, null);
if(c != null) {
c.moveToFirst();
}
return c;
}