我收到这个错误。
09-05 16:17:27.460: E/CursorWindow(29553): Failed to read row 0, column -1 from a CursorWindow which has 1 rows, 8 columns.
09-05 16:17:27.465: E/AndroidRuntime(29553): FATAL EXCEPTION: main
09-05 16:17:27.465: E/AndroidRuntime(29553): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.nesv.landstar/com.nesv.landstar.LandstarPage}: java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.
我不知道我的代码做错了什么。这里是:
Cursor c = null;
try
{
c = landstarDB.rawQuery("SELECT * FROM DriverShipment", null);
}catch (Exception e) {
Log.w("Error selecting table", "Error selecting table");
}
if (c != null && c.moveToFirst()) {
c.moveToFirst();
do {
Log.i("cctid:", c.getString(c.getColumnIndex("cctid")));
if(c.getString(c.getColumnIndex("cctid")) == cctid)
{
isRecorded = true;
shipmentId = c.getString(c.getColumnIndex("cctid"));
origin = c.getString(c.getColumnIndex("origin"));
destination = c.getString(c.getColumnIndex("destination"));
protectTime = c.getString(c.getColumnIndex("protect_time"));
readyTime = c.getString(c.getColumnIndex("ready_time"));
etat = c.getString(c.getColumnIndex("eta"));
if(c.getString(c.getColumnIndex("isAccepted")) == "1")
{
isAccepted = true;
}
}
}while(c.moveToNext());
}
c.close();
有任何想法吗?谢谢!