android.database.CursorIndexOutOfBoundsException:Index 2 req
来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/09/30 18:29:37
android.database.CursorIndexOutOfBoundsException:Index 2 requested,with a size of 2
查询方法:
\x05public Cursor priceQuery(String name)
\x05{
\x05\x05SQLiteDatabase db = DBHelper.getWritableDatabase();\x05
\x05\x05Cursor c = db.rawQuery("select market,price from "+"price"+" where goods = ;",new String[]{""+name});
\x05\x05return c;
\x05}
主程序:
\x05\x05DBAdapter db = new DBAdapter(this);
\x05\x05db.open();
\x05\x05\x05\x05
\x05\x05Cursor c = db.priceQuery(name);
\x05\x05c.moveToFirst();
\x05\x05while(c.moveToNext());
{
\x05HashMap map = new HashMap();
\x05\x05map.put("ItemTitle",c.getString(0));
\x05\x05map.put("ItemPrice",c.getString(1));
\x05\x05listItem.add(map);
}
\x05\x05
c.close();
db.close();
查询方法:
\x05public Cursor priceQuery(String name)
\x05{
\x05\x05SQLiteDatabase db = DBHelper.getWritableDatabase();\x05
\x05\x05Cursor c = db.rawQuery("select market,price from "+"price"+" where goods = ;",new String[]{""+name});
\x05\x05return c;
\x05}
主程序:
\x05\x05DBAdapter db = new DBAdapter(this);
\x05\x05db.open();
\x05\x05\x05\x05
\x05\x05Cursor c = db.priceQuery(name);
\x05\x05c.moveToFirst();
\x05\x05while(c.moveToNext());
{
\x05HashMap map = new HashMap();
\x05\x05map.put("ItemTitle",c.getString(0));
\x05\x05map.put("ItemPrice",c.getString(1));
\x05\x05listItem.add(map);
}
\x05\x05
c.close();
db.close();
数组越界,while中的条件改一下就可以了
...
c.moveToFirst();
while(!c.isAfterLast())
{
HashMap map = new HashMap();
map.put("ItemTitle", c.getString(0));
map.put("ItemPrice", c.getString(1));
listItem.add(map);
c.moveToNext()
}
...
...
c.moveToFirst();
while(!c.isAfterLast())
{
HashMap map = new HashMap();
map.put("ItemTitle", c.getString(0));
map.put("ItemPrice", c.getString(1));
listItem.add(map);
c.moveToNext()
}
...
android.database.CursorIndexOutOfBoundsException:Index 2 req
android.database.CursorIndexOutOfBoundsException: Index -1 r
=INDEX(Database!C4:C64,SMALL(IF(Database!F3:F64=Sheet1!B20,R
DataBase Assistant
list index out of bound(2)
REQ'N for Quote/ purchase
persist database怎么翻译?
DataBase Assistant是什么意思
DATABASE SYSTEMS CONCEPTS怎么样
DATABASE MANAGEMENT SYSTEMS怎么样
开机出现list index out of bounds(2)怎么回事?
matlab index=l(2)+1:l(7)是什么意思