4

I have a non-rooted Droid X2 that is in permanent "Safe mode", but I want to recover SMS messages. SMS Backup and Restore will NOT work because safe mode only allows system apps to run.

adb shell will get me into the phone, but does not allow me to get to the SMS database:

[rjt@pc232 workspace]$ adb shell
$ cat /proc/version
Linux version 2.6.32.9-00008-gc406305 (hudsoncm@il93lnxdroid80) (gcc version 4.4.0 (GCC) ) #2 SMP PREEMPT Tue Jan 24 22:54:19 CST 2012

$ cd /data/data/com.android.providers.telephony/databases/
$ pwd
/data/data/com.android.providers.telephony/databases
$ ls
opendir failed, Permission denied
$ su -l root
su: permission denied
$ sudo
sudo: permission denied
$ sudo su -
sudo: permission denied
$ sudo su -l root
sudo: permission denied
$

Since SMS Backup and Restore is allowed to access my SMS messages when in normal mode, is "Safe mode" blocking my access or the fact that this phone is not rooted?

Can I root the phone without losing my existing SMS messages?

Liam W
  • 8,436
  • 11
  • 40
  • 67
rjt
  • 169
  • 1
  • 1
  • 7

3 Answers3

5

Try this:

cat /data/data/com.android.providers.telephony/databases/mmssms.db > /sdcard/mysms.db

Which copies the SMS database across to the SDCard.

For the Telephone database,

cat /data/data/com.android.providers.telephony/databases/telephony.db > /sdcard/mytelephony.db

Its a very old trick, to pull in the databases without root. It is not guaranteed to work across all ROMs depending on how the directory permissions are set.

t0mm13b
  • 13,436
  • 1
  • 48
  • 58
  • $ cat /data/data/com.android.providers.telephony/databases/mmssms.db /data/data/com.android.providers.telephony/databases/mmssms.db: Permission denied – rjt Jan 12 '13 at 17:56
  • you left out the redirect symbol? as in > – t0mm13b Jan 12 '13 at 17:57
  • Yes i did leave out the redirect because i do not currently have an external sd card. Will try again after inserting card. whoops. i do not have the sdcard with me, do really think it makes a difference? – rjt Jan 12 '13 at 17:58
  • try adb pull /data/... directly? You should have stated explicitly in your question that you do not have an external SD Card! – t0mm13b Jan 12 '13 at 17:59
  • [rjt@pc232 workspace]$ adb pull /data/data/com.android.providers.telephony/databases/mmssms.db failed to copy '/data/data/com.android.providers.telephony/databases/mmssms.db' to './mmssms.db': Permission denied – rjt Jan 12 '13 at 18:01
  • This won't work as the device isn't rooted! The /data partition isn't even readable without root! You need to be rooted, use the su command to enter a root shell, then remount the /data partition as RW. – Liam W Jan 12 '13 at 18:01
  • Liam W, in my initial question, there are demonstrated attempts at sudo and su but permission denied. Am i doing something wrong in regards to su / sudo? – rjt Jan 12 '13 at 18:03
  • @rjt See my answer. Android doesn't come with sudo, and root can only be attained on a rooted device. – Liam W Jan 12 '13 at 18:05
  • So is there some way to root the phone without deleting the existing SMS messages? – rjt Jan 12 '13 at 18:09
  • @rjt See latest edit to my answer. – Liam W Jan 12 '13 at 18:14
  • @LiamW I explicitly stated it is not guaranteed to work across ALL ROMs... some do, un-rooted Froyo on Samsung Europa, that works. Not all do! – t0mm13b Jan 12 '13 at 19:00
  • @t0mm13b, thank you for the help. i did try with an external sdcard, but still get "Permission denied". – rjt Jan 14 '13 at 05:51
  • @t0mm13b, i managed to root the phone and made a backup just as you described. Thank You. – rjt Feb 11 '13 at 21:16
2

You will be unable to do this without a rooted device, as the /data directory can only be read by the Android system, and apps can also read their own /data/data/<package name> directory only.

Android devices do not come with sudo, and you need to be rooted to use su as it switches to the root shell (on unrooted ROM's, su can't switch to the root user, as the kernel denies it).

If you do find a way to root the device, (which may be difficult), you can mount the /data partition as RW, then you can copy files from it.

Use these command to remount the /data patition:

su

mount -o remount,rw /data

The su command can only be executed on a rooted device.

EDIT:

Just for clarification, the SMS Backup & Restore app uses an API call to get the SMS messages via the Messaging app, hence the need for the READ_SMS permission.

EDIT2:

Most rooting methods don't wipe the device data, however some do. You would have to google for a way to root your droid 2 however, and see if it wipes the data.

Liam W
  • 8,436
  • 11
  • 40
  • 67
  • When in "Safe mode", should i be able to install and run applications such as "SMS Backup and Restore" via adb? If so, how? – rjt Jan 12 '13 at 18:16
  • @rjt You can install them most likely, but you won't be able to run them AFAIK. You could try though. Download the apps .apk file, and use adb install <path/to/apk/file> to install it. – Liam W Jan 12 '13 at 18:17
  • Thank You Liam for emphasizing that the phone needed to be rooted first. – rjt Feb 11 '13 at 21:15
0

I'm not sure yet whether this works on non-Google phones, but on my Pixel 2 and Nexus 5, the backup feature (under Settings -> System -> Backup -> (Choose profile, if relevant) -> Pixel 2 backup) shows that SMS text messages are included in the Google Drive backup, if you have enabled it. You cannot directly download or view the backup from Google Drive/PC, but if you have another phone and choose to restore data to it, the SMS messages should be downloaded to the new phone and be available to view and export with a 3rd party app.

Justin
  • 1