Restoring SMS messages using mmssms.db file

My Nexus 5x phone died from the “bootloop” syndrome.  I had unlocked bootloader on it and TWRP recovery image was installed, so I was trying hard to get at least some data off the phone.  Most of the time it would not boot at all, but I managed to boot into TWRP recovery after leaving the phone in the freezer for a few hours.

Once in TWRP, I was able to pull some data using “adb pull”.  This included a file that contains the SMS and MMS messages.  On my Nexus 5x the path to that file was /data/user_de/0/com.android.providers.telephony/databases/mmssms.db.  My plan was to restore that file onto my temporary phone running LineageOS (CyanogenMod 14). I was going to overwrite the file using “adb push” while booted into TWRP recovery.

However, this did not work.  The database file was being ignored by the SMS application. Searching for the problem yielded this comment on stackexchange. The database file contains two crucial parameters: schema_version and user_version. Under LineageOS’s version of mmssms.db they were 44 and 67, respectfully, but the file from Nexus 5x contained 48 and 64. Modifying these two parameters in the file from Nexus 5x was all that was needed for this file to be recognized under LineageOs.

Having gone through this exercise, I really wish Google offered automatic backup for text messages and call logs. (Nominally, they do, but it has never worked for me). Until they do, I am going to start using SMS Backup and Restore app to schedule automatic backups for my phone.

FacebooktwitterredditpinterestlinkedinmailFacebooktwitterredditpinterestlinkedinmail

3 comments

  1. it was 44 and 68 with me and the file mmssms.db-journal can/has to be deleted.
    How I did it:
    -Copy both *original* and *archived* mmssms.db to PC
    -Check the “schema” and “user” versions of your original
    -Change your archived one accordingly
    -Stop your SMS App, delete data and cache
    -Browse to data/user_de/0/com.android.providers.telephony/databases
    -DELETE mmssms.db-journal
    -Copy modified archived version into the folder
    -Restart SMS App

    Took a split second for all my old SMS to reappear 🙂

    Dude, you are my HERO!
    Have a (virtual) beer on me!

Leave a comment

Your email address will not be published. Required fields are marked *