Java 为什么即使在调用moveToNext()之后,android SQLite光标仍位于位置-1?

Java 为什么即使在调用moveToNext()之后,android SQLite光标仍位于位置-1?,java,android,database,sqlite,Java,Android,Database,Sqlite,这段代码以前是有效的,但现在当我在for循环中找到Cursor.get方法时,我得到: android.database.CursorIndexOutOfBoundsException:请求索引-1,大小为5 getCount()方法的大小大于零,但光标仍然不移动 我正在使用SQLiteAssetHelper。 这是我的密码: ArrayList<Profile> GetAllProfiles() throws SQLiteException{ SQLiteDatabase

这段代码以前是有效的,但现在当我在for循环中找到Cursor.get方法时,我得到:

android.database.CursorIndexOutOfBoundsException:请求索引-1,大小为5

getCount()方法的大小大于零,但光标仍然不移动

我正在使用SQLiteAssetHelper。 这是我的密码:

ArrayList<Profile> GetAllProfiles() throws SQLiteException{
    SQLiteDatabase database = this.getReadableDatabase();
    String[] selection = {COL_ID, COL_NAME, COL_IMAGE};
    Cursor c = database.query(TABLE_PLAYERS, selection, null, null, null, null, null);

    ArrayList<Profile> profiles = new ArrayList<>();

    int colIndexID = c.getColumnIndex(COL_ID);
    int colIndexName = c.getColumnIndex(COL_NAME);
    int colIndexImage = c.getColumnIndex(COL_IMAGE);

    for(c.moveToFirst(); !c.isAfterLast(); c.moveToNext())
    {
        profiles.add(new Profile(
        c.getInt(colIndexID),
        c.getString(colIndexName),
        c.getBlob(colIndexImage)));
    }

    database.close();
    return profiles;
}
ArrayList GetAllProfiles()引发SQLiteException{
SQLiteDatabase=this.getReadableDatabase();
String[]selection={COL_ID,COL_NAME,COL_IMAGE};
游标c=数据库.query(表,选择,空,空,空,空,空,空);
ArrayList profiles=新的ArrayList();
int colIndexID=c.getColumnIndex(列ID);
int colIndexName=c.getColumnIndex(列名称);
int colIndexImage=c.getColumnIndex(COL_图像);
for(c.moveToFirst();!c.isAfterLast();c.moveToNext())
{
配置文件。添加(新配置文件)(
c、 getInt(colIndexID),
c、 getString(colIndexName),
c、 getBlob(colIndexImage));
}
close()数据库;
返回配置文件;
}

错误发生在哪一行?第一次运行应用程序后,您是否更改了任何列名或在表中添加了任何新列?图像blob列提示您数据库中的行可能太大,移动失败。Android光标窗口限制为2MB。