Search code examples
androidandroid-contentprovidersqlexception

SQLException in contentProvider


Everybody knows NotePad exaple for android. Its content provider contains "throw new SQLException("Failed to insert row into " + uri);" in the end of insert method, but when I try to use this row in my own contentProvider Eclipse shows an error "Unhandled exception type SQLException".

How can I throw this Exception from this method?


Solution

  • You need to tell the compiler that this method will throw this exception so add "throws SQLException" to your method header e.g.

    public Uri insert(Uri uri, ContentValues values) throws SQLException {
        //dostuff
    }