title: How to get error code of SQLiteConstraintException in Java
body: <p>I'm trying to catch the following exception specifically for <strong>code 19.</strong> 
  Is there any way of getting <a href="https://www.sqlite.org/c3ref/c_abort.html" rel="nofollow">the error code</a> of SQLiteConstraintException ? or should I simply have a "contains" check for the message description ? </p>
  
  <p>03-24 14:46:45.430: W/System.err(2219): android.database.sqlite.<strong>SQLiteConstraintException</strong>: PRIMARY KEY must be unique (code 19)</p>
  
  <pre><code>        try {
              res = database.insertOrThrow(EMP_TABLE, null, values);      
          } catch (android.database.sqlite.SQLiteConstraintException e) {
               e.printStackTrace();
               //something like e.getErrorCode(); }
  </code></pre>
  
  <p>My workaround solution is ; </p>
  
  <pre><code>    if(e.getMessage().contains("code 19"))
        Log.d(TAG, "Key Already exists !");
  </code></pre>