Java 从Sql数据库到阵列的数据

Java 从Sql数据库到阵列的数据,java,android,sql,arrays,eclipse,Java,Android,Sql,Arrays,Eclipse,我想将Sql数据库中的一些数据放入数组中 以下是我的阵列代码: openDB(); Cursor c = myDb.getSpalte(); while (!c.isAfterLast()) { s1nInt[i] = c.getInt(1); i++; c.moveToNext(); } c.close(); closeDB(); 这是我的getSpalte()代码方法: public Cursor getSpal

我想将Sql数据库中的一些数据放入数组中

以下是我的阵列代码:

openDB();
Cursor c = myDb.getSpalte();
while (!c.isAfterLast()) 
     {
         s1nInt[i]  = c.getInt(1);
         i++;
         c.moveToNext();
     }
c.close();
closeDB();
这是我的
getSpalte()代码方法:

public Cursor getSpalte()
{
    String where= null;
    Cursor c =  db.query(true, DATABASE_TABLE, KEY_KALOA, 
            where, null, null, null, null, null);
    if (c != null) 
    {
      c.moveToFirst();
    }
  return c;
}
如果我运行这个,我会得到以下异常:

06-27 13:34:01.021: E/CursorWindow(24334): Failed to read row 0, column 1 from a CursorWindow which has 1 rows, 1 columns.
现在,对于这些命令,我得到了一个例外:

  Number[] series2Numbers = {/*s1nInt[i-6],s1nInt[i-5],s1nInt[i-4],s1nInt[i-3],s1nInt[i-   2],s1nInt[i-1],*/s1nInt[i]};
这是我的例外:

Graph.onStart() line: 75    
Graph(Fragment).performStart() line: 1801   
FragmentManagerImpl.moveToState(Fragment, int, int, int, boolean) line: 937 
FragmentManagerImpl.moveToState(int, int, int, boolean) line: 1106  
BackStackRecord.run() line: 690 
FragmentManagerImpl.execPendingActions() line: 1571 
FragmentManagerImpl$1.run() line: 447   
Handler.handleCallback(Message) line: 733   

光标从0开始,在访问数据之前必须移动到第一行:

     while(c.moveToNext())
     {
         s1nInt[i]  = c.getInt(1);
         i++;
     }
谢谢,它能工作:)但是你能帮我解决下一个问题吗?:)