How to import an existing mmssms.db to an Android Virtual Device?


Question

I've downgraded from Cyanogenmod 13 (Android 6.0.1) to Android stock 5.1.1, and kept my previous mmssms.db file, but it is incompatible with older Android versions. I would like to import this database in an Android Virtual Device running Android 6.0, back it up using SMS Save & Restore, then restore the .xml file produced by that app on my device.



However, when I copy my old com.android.providers.telephony directory in the /data/data/ directory of the AVD, neither the Messenger app, nor SMS Backup & Restore see any message. The directory and its contents are owned by the radio user, belong to the radio group, and have chmod set to 771.



How can I check what is preventing the system from accessing my database?



Or how else can I retrieve my sms ?


Answer

I've finally managed to restore the contents of my previous database on my current device and I will explain how.



The idea was to copy the backup of /data/data/com.android.providers.telephony from my previous installation, to an Android Virtual Device, back it up there using SMS Backup & Restore in XML format, then restore that XML backup on my device. SMS Backup & Restore merged the messages from the backup with the current device's messages so I didn't have to merge the two databases by hand.



In my question, the AVD running 6.0.0 wouldn't read the contents of my database because it was created on CM 13 which is based on Android 6.0.1. But Google doesn't seem to provide an emulator image based on Android 6.0.1, so I still used an AVD running 6.0.0. For performance reasons I've configured it to emulate an Intel Atom (x86) CPU and installed Intel HAXM driver on my PC (I've followed this answer to do that).



The mmssms.db database holds properties about itself, especially version numbers, so I've edited them to make Android believe that it dealt with a database of a version it could deal with. I've opened mmssms.db in SQLite Expert, clicked on the "Database" tab, and in the property list, found the following lines:




  • schema_version

  • user_version



I've downgraded these to 44 and 60, respectively.



Then I transferred my backup of /data/data/com.android.providers.telephony to the AVD using adb push, after making sure that location was already empty there. Using adb shell I've set the owner and group of everything in this directory and its subdirectories to radio, and in the database subdirectory the chmod value to 660.



I've rebooted the device.



I've installed SMS Backup & Restore on the AVD through ADB. (The .apk of that app can be found on an existing device in /data/app on a device where it is already installed. I didn't bother installing Google Play Services on the emulator to get it from the Play Store, but you can do that.)



I've backed up the messages and copied the resulting .xml over to my real device, where I've used SMS Backup & Restore to restore it. Voilà.


Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes