我的inv.db有以下内容
从库存中选择*;
Failed to read row 0, column -1 from a CursorWindow which has 2 rows, 3 columns.
Couldn't read row 0, col -1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.
然而我收到错误
// Find the columns of pet attributes that we're interested in
int nameColumnIndex = cursor.getColumnIndex(InventoryContract.InventoryEntry.COLUMN_PRO_NAME);
int priceColumnIndex = cursor.getColumnIndex(InventoryContract.InventoryEntry.COLUMN_PRO_PRICE);
int quanColumnIndex = cursor.getColumnIndex(InventoryContract.InventoryEntry.COLUMN_PRO_QUAN);
int supColumnIndex = cursor.getColumnIndex(InventoryContract.InventoryEntry.COLUMN_PRO_SUP);
// Read the pet attributes from the Cursor for the current pet
String petName = cursor.getString(nameColumnIndex);
String price = cursor.getString(priceColumnIndex);
String quantity = cursor.getString(quanColumnIndex); // produces error
但是除了id之外还有四列。
"scripts": {
...
"pree2e": "webdriver-manager update --standalone false --gecko false",
"e2e": "protractor"
}
我不确定这里有什么问题。如果我删除最后一行代码,我的代码就会运行
答案 0 :(得分:0)
您的光标已正确初始化,但无法在InventoryContract.InventoryEntry.COLUMN_PRO_QUAN
找到字符串的列索引
确保存储在那里的字符串与列名相匹配。现在它可能不正确