我无法在android中创建带有光标数据的字符串数组

时间:2011-12-11 12:10:48

标签: android sqlite cursor

private static final String Memo_Name = "MemoName"; 

openDB();
            String[] col = new String[] {Memo_Name};
            Cursor c = db.query(Memo_Table, col, null, null, null, null, null);
            String[] result = new String[c.getCount()-1];
                 if(c.moveToFirst()){
                      for (int i = 0; i < c.getCount(); i++){
                          result[i] = c.getString(c.getColumnIndex(Memo_Name));
                          c.moveToNext();
                        }//end of for
                 }
                db.close();
此行

ArrayIndexOutOfBoundsException

result [i] = c.getString(c.getColumnIndex(Memo_Name));

1 个答案:

答案 0 :(得分:2)

很高兴我能提供帮助。 这样你就可以关闭这个问题 -

删除“-1”