小编bog*_*dan的帖子

SQLiteConstraintException未被捕获

这段代码有什么问题?它不会捕获insertChild()方法抛出的异常.

childDbOps.open();
try {
    childDbOps.insertChild(child);
} catch (SQLiteException exception) {
    Log.i("error la inserare child", "on the next line");
    exception.printStackTrace();
} finally {
    childDbOps.close();
}
Run Code Online (Sandbox Code Playgroud)

错误是:

ERROR/Database(320): android.database.sqlite.SQLiteConstraintException: error code 19: 
constraint failed at com.android.dataLayer.DbAdapter.insertChild(DbAdapter.java:169) 
  at com.android.activities.ChildInsertActivity.onClick(ChildInsertActivity.java:203) 
  at android.view.View.performClick(View.java:2344) 
Run Code Online (Sandbox Code Playgroud)

这是android sqlite.该行是在调用insert方法时.

java android exception-handling try-catch

9
推荐指数
2
解决办法
1万
查看次数

标签 统计

android ×1

exception-handling ×1

java ×1

try-catch ×1