Hi in my project i need to handling the exception like duplicate value,empty field etc.. I thought of using the try catch method for this
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;
}
}
I am able to get the error but i need to handle it and sent some message to the user to enter again so i though of doing like this with help of 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;
}
}
but there is no method as getErrorCode()
in SQLException when i check mSQLException.
but it is there in android document can any one help me