java.lang.IllegalStateException: get field slot from row 0 col -1 failed

09-07 16:18:14.358: ERROR/AndroidRuntime(29185): Caused by: java.lang.IllegalStateException: get field slot from row 0 col -1 failed
09-07 16:18:14.358: ERROR/AndroidRuntime(29185): at android.database.CursorWindow.getLong_native(Native Method)
09-07 16:18:14.358: ERROR/AndroidRuntime(29185): at android.database.CursorWindow.getInt(CursorWindow.java:434)
09-07 16:18:14.358: ERROR/AndroidRuntime(29185): at android.database.AbstractWindowedCursor.getInt(AbstractWindowedCursor.java:93)
09-07 16:18:14.358: ERROR/AndroidRuntime(29185): at com.ceosoftcenters.healyourbody.app.HealYourBodyApplication.setProblemDataSet(HealYourBodyApplication.java:108)
09-07 16:18:14.358: ERROR/AndroidRuntime(29185): at com.ceosoftcenters.healyourbody.app.HealYourBodyApplication.onCreate(HealYourBodyApplication.java:49)
09-07 16:18:14.358: ERROR/AndroidRuntime(29185): at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:969)
09-07 16:18:14.358: ERROR/AndroidRuntime(29185): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4244)
09-07 16:18:14.358: ERROR/AndroidRuntime(29185): ... 10 more


代码:

SQLiteDatabase database = SQLiteDatabase.openOrCreateDatabase(appFilesDir.getAbsolutePath() + ConstantsUtil.HEAL_YOUR_BODY_DBFILE_PATH, null);
// query all data
String sql = "select id,problem from bookdata";
Cursor cursor = database.rawQuery(sql,null);
if (cursor.getCount() > 0)
{
cursor.moveToFirst();
ProblemData pd = null;
while(!cursor.isLast()){
int id = cursor.getInt(cursor.getColumnIndex("id"));
String problemName = cursor.getString(cursor.getColumnIndex("problem"));
pd = new ProblemData(id,problemName);
problemDataSet.add(pd);
cursor.moveToNext();
}

int id = cursor.getInt(cursor.getColumnIndex("id"));
String problemName = cursor.getString(cursor.getColumnIndex("problem"));
pd = new ProblemData(id,problemName);
problemDataSet.add(pd);
}


原因:字段写错了,

solution: ID Problem





你可能感兴趣的:(java.lang.IllegalStateException: get field slot from row 0 col -1 failed)