当我想为玩家保存结果时,我会调用此方法。但当我取消注释应用程序崩溃的最后一行时,任何人都可以看到任何明显的错误吗?当最后一行被评论时,它运行顺畅,所以似乎没有其他错误。
public void saveHoleResult(PlayerResult playerResult, int hole, int result)
{
playerResult.setResult(hole, result);
long id = playerResult.getId();
String resultString = playerResult.getResultString();
ContentValues values = new ContentValues();
values.put(MySQLiteHelper.COLUMN_PLAYERRESULTS_RESULTS, resultString);
//database.update(MySQLiteHelper.TABLE_PLAYERRESULTS, values, MySQLiteHelper.COLUMN_PLAYERRESULTS_ID + " = " + id, null);
}
这是logcat:
02-15 18:02:53.238:D / AndroidRuntime(1157):关闭VM 02-15 18:02:53.248:W / dalvikvm(1157):threadid = 1:线程退出,未捕获异常(group = 0x2bd39930) 02-15 18:02:53.258:E / AndroidRuntime(1157):致命异常:主要 02-15 18:02:53.258:E / AndroidRuntime(1157):java.lang.IllegalStateException:尝试重新打开已关闭的对象:SQLiteDatabase:/data/data/com.example.egta/databases/egta。 D b 02-15 18:02:53.258:E / AndroidRuntime(1157):在android.database.sqlite.SQLiteClosable.acquireReference(SQLiteClosable.java:55) 02-15 18:02:53.258:E / AndroidRuntime(1157):在android.database.sqlite.SQLiteDatabase.updateWithOnConflict(SQLiteDatabase.java:1534) 02-15 18:02:53.258:E / AndroidRuntime(1157):在android.database.sqlite.SQLiteDatabase.update(SQLiteDatabase.java:1514) 02-15 18:02:53.258:E / AndroidRuntime(1157):at com.example.egta.PlayerResultsDataSource.saveHoleResult(PlayerResultsDataSource.java:60) 02-15 18:02:53.258:E / AndroidRuntime(1157):at com.example.egta.FinishHoleActivity $ 2.onClick(FinishHoleActivity.java:126) 02-15 18:02:53.258:E / AndroidRuntime(1157):at com.android.internal.app.AlertController $ ButtonHandler.handleMessage(AlertController.java:166) 02-15 18:02:53.258:E / AndroidRuntime(1157):在android.os.Handler.dispatchMessage(Handler.java:99) 02-15 18:02:53.258:E / AndroidRuntime(1157):在android.os.Looper.loop(Looper.java:137) 02-15 18:02:53.258:E / AndroidRuntime(1157):在android.app.ActivityThread.main(ActivityThread.java:5039) 02-15 18:02:53.258:E / AndroidRuntime(1157):at java.lang.reflect.Method.invokeNative(Native Method) 02-15 18:02:53.258:E / AndroidRuntime(1157):at java.lang.reflect.Method.invoke(Method.java:511) 02-15 18:02:53.258:E / AndroidRuntime(1157):at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:793) 02-15 18:02:53.258:E / AndroidRuntime(1157):at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 02-15 18:02:53.258:E / AndroidRuntime(1157):at dalvik.system.NativeStart.main(Native Method)