【发布时间】:2014-03-04 09:14:20
【问题描述】:
嗨,在我的项目中,我需要处理重复值、空字段等异常。我想为此使用 try catch 方法
public void deleteRegisterID(Object object) {
SQLiteDatabase oDBLocal = this.getWritableDatabase();
try {
oDBLocal.execSQL("delete from " + STRTABLE_REGISTER + " where " + KEY_ID
+ " = " + object + ";");
}catch (SQLException mSQLException) {
Log.e("Loginerror", "getproductData >>" + mSQLException.toString());
throw mSQLException;
}
}
我能够得到错误,但我需要处理它并向用户发送一些消息以再次输入,所以我想在this 的帮助下这样做
catch (SQLException mSQLException)
{
switch (mSQLException.getErrorCode ())
{
case 19:
//some toast message to user.
break;
case 11:
//some toast message to user.
break;
default:
throw mSQLException;
}
}
但是当我检查mSQLException.时,SQLException中没有getErrorCode()这样的方法,但它在android文档中有任何人可以帮助我
【问题讨论】:
标签: android database sqlite exception sqlexception