My phone just decided that it should spam an exception onto my screen that reopens as soon as I tap it away.

A look at logcat reveals the following being thrown multiple times per second:

SQLiteLog: (14) cannot open file at line 34327 of [605907e73a]
SQLiteLog: (14) os_unix.c:34327: (13) open(/data/user/0/com.android.providers.contacts/databases/contacts2.db-shm) -
SQLiteLog: (14) statement aborts at 1: [PRAGMA user_version;] unable to open database file
SQLiteLog: (14) cannot open file at line 34327 of [605907e73a]
SQLiteLog: (14) os_unix.c:34327: (13) open(/data/user/0/com.android.providers.contacts/databases/contacts2.db-shm) -
AndroidRuntime: FATAL EXCEPTION: Worker-1
AndroidRuntime: Process: android.process.acore, PID: 9149
AndroidRuntime: android.database.sqlite.SQLiteCantOpenDatabaseException: unable to open database file (code 14)
AndroidRuntime:        at android.database.sqlite.SQLiteConnection.nativeExecuteForLong(Native Method)
AndroidRuntime:        at android.database.sqlite.SQLiteConnection.executeForLong(SQLiteConnection.java:599)
AndroidRuntime:        at android.database.sqlite.SQLiteSession.executeForLong(SQLiteSession.java:652)
AndroidRuntime:        at android.database.sqlite.SQLiteStatement.simpleQueryForLong(SQLiteStatement.java:107)
AndroidRuntime:        at android.database.DatabaseUtils.longForQuery(DatabaseUtils.java:842)
AndroidRuntime:        at android.database.DatabaseUtils.longForQuery(DatabaseUtils.java:830)
AndroidRuntime:        at android.database.sqlite.SQLiteDatabase.getVersion(SQLiteDatabase.java:940)
AndroidRuntime:        at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:311)
AndroidRuntime:        at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:262)
AndroidRuntime:        at com.android.providers.contacts.LegacyApiSupport.<init>(LegacyApiSupport.java:499)
AndroidRuntime:        at com.android.providers.contacts.ContactsProvider2.initForDefaultLocale(ContactsProvider2.java:1668)
AndroidRuntime:        at com.android.providers.contacts.ContactsProvider2.performBackgroundTask(ContactsProvider2.java:1759)
AndroidRuntime:        at com.android.providers.contacts.ContactsProvider2$1.onPerformTask(ContactsProvider2.java:1615)
AndroidRuntime:        at com.android.providers.contacts.ContactsTaskScheduler$MyHandler.handleMessage(ContactsTaskScheduler.java:77)
AndroidRuntime:        at android.os.Handler.dispatchMessage(Handler.java:106)
AndroidRuntime:        at android.os.Looper.loop(Looper.java:164)
AndroidRuntime:        at android.os.HandlerThread.run(HandlerThread.java:65)

My guess would be, that - for whatever reason - the contacts provider was assigned a different user ID and has now lost access to it's own database. I would guess, that if I clear the database the issue is gone.

Still, I don't want to lose my contacts. I have a backup but that's old enough to say that I would lose some. I'm convinced that the file is still there and I can probably just open it as sqlite file once I gain access but I have no clue on how to achieve this. Trying to work with the com.android.providers.contacts package in adb always leaves me with "package not debuggable".

My Phone is a non-rooted Moto G5 Plus running Android 8.1

Is there a way to backup my contacts or are they gone? Also: Can I maybe just remove the *.db-shm file that seems to be the problem here? As far as I remember that's only some temp file for sqlite anyways.


I posted this question trying to find a solution for about an hour and just 10 minutes later I finally found it myself.

Going into the adb shell and running

pm clear com.android.providers.contacts

does not require root privileges and clears the cache, which seems to include the *.db-shm file.

I'm keeping this question here for future reference

EDIT: This was a misinformation. After further inspection I found out that, pm clear does in fact clear all app data, so don't run it if you only want to clear an app's cache. That command is essentially the same as clicking on the Clear Data button in the app preferences.

The reason why this worked out for me is, that the contacts themselves are stored separately. The com.android.providers.contacts package loads the contacts from that other place and provides it to other apps and therefore is called contacts provider.

The data in the provider's db seems to only be things like the call log and the contacts you recently shared something with. Deleting this data is totally fine and fixes the issue.

  • It is allowed to answer your own question. – Reddy Lutonadio Jan 28 '19 at 17:43
  • @ReddyLutonadio I know, that's why I did it. As a stackoverflow user I hate when I find my exact issue in a question without an answer. I always wonder if people just gave up or didn't bother to provide a solution when they found it. – Link64 Jan 28 '19 at 17:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.