嗨處理。我想到了使用嘗試捕捉方法,這的SQLException錯誤在我的項目,我需要像處理重複值,空場等異常Android中
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;
}
}
幫助,但沒有方法getErrorCode()
中的SQLException當我檢查mSQLException.
但在那裏Android的文檔可以幫助我的任何人