android - How to handle "SQLiteException: null" from ContentResolver.applyBatch? -


i have implemented syncadapter writes data android contacts provider. mostly, appears working fine, except small percentage of users, see app crash every time syncadapter fires! when recover logs these devices (primarily samsung devices running android 5+), see:

exception: android.database.sqlite.sqliteexception: null @ android.database.databaseutils.readexceptionfromparcel(databaseutils.java:181) @ android.database.databaseutils.readexceptionwithoperationapplicationexceptionfromparcel(databaseutils.java:160) @ android.content.contentproviderproxy.applybatch(contentprovidernative.java:520) @ android.content.contentproviderclient.applybatch(contentproviderclient.java:402) @ android.content.contentresolver.applybatch(contentresolver.java:1297) 

now, appears contentproviderproxy.applybatch works bundling data message sent via ibinder whatever service in charge of managing contacts database. in turn, receives message back, , passes along databaseutils.readexceptionwithoperationapplicationexceptionfromparcel. function inspects reply, , based upon passed code, supposed throw exception string message in reply. unfortunately, in case, although service has set code in reply, there no message set; , that's why see sqliteexception: null , left no clue i'm doing wrong.

is else experiencing error, , if so, can me narrow down happening in case? thanks!

i ran it. it's caused contacts database corruption. full details on post samsung developers forum.

the workaround found catch sqliteexception in syncing method, inform user has clear contacts database (he might lose local contacts!). intent is:

intent detailsintent = new intent(android.provider.settings.action_application_details_settings); detailsintent.setdata(uri.parse("package:com.android.providers.contacts")); 

once data cleared, contacts resync , database rebuilt properly.


Comments