• Home
  • MAD
  • Concept Series
    • Software Design
    • Software Arch
    • GIT & Github
    • System Design
    • Cloud
    • Database Integration
    • Push Notification
    • API Integration
    • Cocoa PODS
  • DSA
  • Interview
  • Tips&Tricks
  • YT
  • Home
  • MAD
  • Concept Series
    • Software Design
    • Software Arch
    • GIT & Github
    • System Design
    • Cloud
    • Database Integration
    • Push Notification
    • API Integration
    • Cocoa PODS
  • DSA
  • Interview
  • Tips&Tricks
  • YT
  • #News
  • #APPS
  • #Events
    • #WWDC
    • #I/O
    • #Ignite
  • #Let’s Talk

MyCodeTips mycodetips-newlogocopy1

  • Home
  • MAD
  • Concept Series
    • Software Design
    • Software Arch
    • GIT & Github
    • System Design
    • Cloud
    • Database Integration
    • Push Notification
    • API Integration
    • Cocoa PODS
  • DSA
  • Interview
  • Tips&Tricks
  • YT
Android, Programming, Tips&Tricks

How to Backup Contacts and SMS Messages using command line in Android

Backup Contacts and SMS

The messages are available via the Telephony and contacts via the Contacts provider. The data is stored in SQLite databases in the following locations:

/data/data/com.android.providers.telephony/databases/mmssms.db
/data/data/com.android.providers.contacts/databases/contacts2.db
If you have the Android SDK installed and the phone connected to you computer, to do the backup, you simply need to copy these files from the phone to the computer. You can do this with the “adb pull” command. Here are the commands:

cd <android-sdk-dir>/platform-tools
./adb pull /data/data/com.android.providers.telephony/databases/mmssms.db
./adb pull /data/data/com.android.providers.contacts/databases/contacts2.db
After executing this commands you’ll have the databases in your “<android-sdk-dir>/platform-tools” folder. If you want to examine the databases you can use some SQLite browser. I’m using the SQLite Manager addon for Firefox.

If you want to put the backed up files back on the phone, you’ll have to remount the /system partition in read-write mode, delete the present database files (if there are [present) and push the files back on the phone.

First check to see where the which physical partition is mounted on “/system” to know where you should remount it:

./adb shell mount
Search for the “/dev/block/” part on the line with “/system”. On my phone which is running CyanogenMod 6 it is “/dev/block/mtdblock3″.

After discovering which physical partition is mounted at “/system” you will have to remount that partition as read-write, delete the databases and push the backed up ones.

./adb shell mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
./adb shell rm /data/data/com.android.providers.telephony/databases/mmssms.db
./adb shell rm /data/data/com.android.providers.contacts/databases/contacts2.db
./adb push mmssms.db /data/data/com.android.providers.telephony/databases/
./adb push ~/Desktop/phone/contacts2.db /data/data/com.android.providers.contacts/databases/
After doing the restoration of the databases if it happens that you don’t see either your SMS messages or your contacts you can try copying the databases to your SD card and then by using some file manager with root privileges to place them on the appropriate places.

For more details please refer http://chombium.wordpress.com/2012/09/30/android-how-to-backup-contacts-and-sms-messages/

Liked it? Take a second to support Ranjan on Patreon!
become a patron button
  • Click to share on Reddit (Opens in new window)
  • Click to share on Facebook (Opens in new window)
  • Click to share on Twitter (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Tumblr (Opens in new window)
  • More
  • Click to share on Pocket (Opens in new window)
  • Click to share on Pinterest (Opens in new window)
Written by Ranjan - 9297 Views
Tags | Android
AUTHOR
Ranjan

Namaste, My name is Ranjan, I am a graduate from NIT Rourkela. This website is basically about of what i learnt from my years of experience as a software engineer on software development specifically on mobile application development, design patterns/architectures, its changing scenarios, security, troubleshooting, tools, tips&tricks and many more.

You Might Also Like

mycodetips-newlogo2

How to prevent SQL Injection in iOS apps?

October 7, 2013
1326275576 android

Tips on Android ListView and custom adapter

February 11, 2014
thumb-android-files-folders

Android Application File Structure

July 14, 2021
Next Post
Previous Post

Support us

mycodetips
mycodetips

Follow us @ LinkedIn 2850+

Subscribe for updates

Join 8,213 other subscribers

Latest Posts

  • YT-Featured-solidprinciples
    SOLID Principles of Software Design
  • IOS 16 Features
    Latest features in IOS 16
  • r-language
    How can R language be used for data analysis?
  • wordpress-coding-blog
    Guide To WordPress Coding Standards
  • YT-Featured-Algorithm
    What is Algorithm?
  • Frameworks of IOS
    Frameworks of IOS – Part ( I )
  • NSFileManager or NSPathUtilities
    NSFileManager or NSPathUtilities in Objective-C
  • Passing data between view controllers in Objective-C
    Passing data between view controllers in Objective-C
  • structures-classes-enum
    Structures and Classes in swift !
  • control-system-swift
    Control Flow in Swift
whiteboard

Whiteboard(PRO)

whiteboard

Whiteboard(lite)

alphabets

Kids Alphabet

techlynk

Techlynk

techbyte

Do2Day

techbyte

Techbyte

  • #about
  • #myapps
  • #contact
  • #privacy
  • #Advertise
  • #myQuestions

Android Android Studio API APP Programming Apps blogging CSS DATABASE dsa Features HTML HTML5 installation Interview Questions IOS iPhone javascript Mac objective-c OS Programming quicktips SDK SEO SQL swift Tips & Tricks Tools UI Web Wordpress Xcode

  • SOLID Principles of Software Design
  • Latest features in IOS 16
  • How can R language be used for data analysis?
  • Guide To WordPress Coding Standards
  • What is Algorithm?

©mycodetips.com