1

我想将“所有字符串”数据(从“光标”获取)放入“数组”中。但我不知道为什么“数组”只返回一个值?我在这里迷路了。有人能帮我吗?这是我的代码片段

private String[] getOneColumn(){        
    String[] myArray = null;        
    Cursor cursor = mDbHelper.fetchAllNotes();
    startManagingCursor(cursor);

    if(cursor.moveToFirst()){
        String myTitle = cursor.getString(cursor.getColumnIndex(SBooksDbAdapter.KEY_TITLE_RAW));
        myArray = myTitle.split(";");           
    }   

    return myArray;
}
4

1 回答 1

2

我建议你在这里这里看看使用游标和数据库的一些很好的例子(游标对我来说也有点麻烦)。

至于手头的问题,我认为您忘记遍历光标的数据(cursor.moveToNext(), cursor.moveToPosition(int))。

祝你好运。

于 2009-08-30T10:49:25.720 回答