SQLite Android Logcat error for select statement



>02-23 20:16:17.499: E/AndroidRuntime(25817): java.lang.RuntimeException: 无法启动活动 ComponentInfo{com.example.makkosarka/com.example.makkosarka.Table.Table}:java.lang.RuntimeException: 无法启动活动 ComponentInfo{com.example.makkosarka/com.example.makkosarka.Table.Liga1}: java.lang.IllegalArgumentException: 列 '_id' 不存在

以下是尝试从此表中选择记录的方法,然后显示在列表视图中

    private void populateListFromDB(){
        Cursor cursor = myDB.getAllRows("1");
        startManagingCursor(cursor);

        String[] columnFromTable = new String[]
    {DBadapter.KEY_HOSTID, DBadapter.GUESTID, DBadapter.KEY_HSCORE , DBadapter.KEY_GSCORE };

 int[] toLayoutFild = new int[] {R.id.txtview_name, R.id.txtview_gameno, R.id.txtview_won, R.id.txtview_lost, };
SimpleCursorAdapter myCursorAdapter = new SimpleCursorAdapter(this, R.layout.rowlayout,
cursor, columnFromTable, toLayoutFild);
ListView mylistview = (ListView) findViewById(R.id.listview_table);
mylistview.setAdapter(myCursorAdapter);
}

这是在适配器类中,我什至没有选择"_id"(KEY_ROWID)列

  public static final String[] ALL_COLUMNS = new String[] {KEY_HOSTID, KEY_GUESTID,
 KEY_HSCORE, KEY_GSCORE};
    public Cursor getAllRows(String league) {
    Cursor c = db.query(true, DUELS_TABLE, ALL_COLUMNS, 
                        null, null, null, null, null, null);
      if (c != null) {
     c.moveToFirst();
        }
      return c;
     }

该错误意味着什么,是否有可能根本不创建表?我有两个表,我使用相同的方法为另一个选择记录,它工作得很好,但为此它显示了这个问题顶部列出的此错误

这是在适配器类中,我什至没有选择"_id"(KEY_ROWID)列

CursorAdapter及其子类要求Cursor具有名为 _id 的列。如果您有,请使用自己的列,或者切换到rawQuery()以便ROWID AS _id包含在要返回的列列表中。

最新更新