title: How to handle "SQLiteException: null" from ContentResolver.applyBatch?
body: <p>I have implemented a SyncAdapter which writes data to the Android Contacts Provider. Mostly, this appears to be working fine, except for a small percentage of my users, who see the app crash every time the SyncAdapter fires! When I recover the logs from these devices (primarily Samsung devices running Android 5+), this is what I see:</p>
  
  <pre><code>exception: android.database.sqlite.SQLiteException: null
  at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:181)
  at android.database.DatabaseUtils.readExceptionWithOperationApplicationExceptionFromParcel(DatabaseUtils.java:160)
  at android.content.ContentProviderProxy.applyBatch(ContentProviderNative.java:520)
  at android.content.ContentProviderClient.applyBatch(ContentProviderClient.java:402)
  at android.content.ContentResolver.applyBatch(ContentResolver.java:1297)
  </code></pre>
  
  <p>Now, it appears that <code>ContentProviderProxy.applyBatch</code> works by bundling up its data into a message which is sent via IBinder to whatever service is in charge of managing the contacts database. In turn, it receives a message back, and then passes that along to <code>DatabaseUtils.readExceptionWithOperationApplicationExceptionFromParcel</code>. This function inspects the reply, and based upon the passed code, is supposed to throw an Exception with the <code>String</code> message in the reply. Unfortunately, in this case, although the service has set a code in the reply, there is no message set; and that's why I see <code>SQLiteException: null</code> and I am left with no clue about what I'm doing wrong.</p>
  
  <p>Is anyone else experiencing this error, and if so, can you help me narrow down what is happening in this case? Thanks!</p>