无法读取第0行第3730列

时间:2015-05-19 08:50:06

标签: java android cursor spinner adapter

这是我的代码:

dbAdapterdepartamento = new DBAdapterDepartamento(new Sqlitebbdd(
                getApplicationContext()));

        Cursor cdept=dbAdapterdepartamento.getAllDepartamentos();
        cdept.moveToFirst();


        while (cdept.isAfterLast() == false) {
          if (cdept.getFloat(cdept.getColumnIndex("_id")) == 0) {
              String title = cdept.getString(cdept.getColumnIndex("departamento"));
              Log.e("",""+title);
          }       
          cdept.moveToNext();
        }
        cdept.moveToNext();


        departamentoSpinnerAdapter = new SimpleCursorAdapter(this,
                android.R.layout.simple_spinner_dropdown_item,
                cdept,
                new String[] { Tablas.ColumnDEPARTAMENTO.NOMBRE_DEPARTAMENTO },
                new int[] { android.R.id.text1 },
                SimpleCursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);

        sp2 = (Spinner) findViewById(R.id.spinner2);
        sp2.setAdapter(departamentoSpinnerAdapter);
        sp2.setOnItemSelectedListener(this);

游标只有28行和2列,但每次都返回大量列。这是错误:

  

无法从CursorWindow读取第0行,第3730行,即28   行,2列。

1 个答案:

答案 0 :(得分:1)

我认为你的数据库

      String title = cdept.getString(cdept.getColumnIndex("departamento"));

有关

  

第0行,列离开

保持编号3730,实际上您的数据库表结构没有索引为3730的列

因此,表值中包含错误值的问题可能是插入问题