每个人都知道Android的NotePad exaple。它的内容提供程序包含“throw new SQLException(”无法将行插入“+ uri”);“在insert方法的最后,但是当我尝试在我自己的contentProvider中使用此行时,Eclipse显示错误“未处理的异常类型SQLException”。
如何从此方法中抛出此异常?
答案 0 :(得分:2)
您需要告诉编译器此方法将抛出此异常,因此将“throws SQLException”添加到方法头中,例如。
public Uri insert(Uri uri, ContentValues values) throws SQLException {
//dostuff
}