Backing up SMS on HTC Desire (Android)


My HTC Desire is getting sluggish under the weight of all those smses I’ve sent and received. I’d like to back them up and delete them from the phone.

The easiest thing (and, actually, the thing I most want to do) is just take a copy of the sms database.  However:

* you can’t just copy the database which holds these things because … well for some reason they’ve decided to lock owners out of their own phone (if the phone is rooted then this can be done);

* all of the SMS back up utilities I’ve looked at have something wrong with them  – they seem mainly to be designed to backup and restore to a given device, not store an archive of the smses;

* the Desire itself comes with a backup utility … which apparently encrypts the backup file so you can’t read it, but even still it’s no good to me because apparently Telstra removed it before selling me the phone.  FFS

It seems like I need to write my own backup utility to replicate the sms data.

<sigh> (@15:53)

edit (16:15): Apparently reading all sms with scripting layer for Android takes about 6 lines of code.   Now I just need to find a way to query  the contacts to match up the names to the numbers.

edit (16:40): basic code is this (after another 30 mins or so, including updating to sl4a etc):

import android
import cPickle as pickle

droid = android.Android()

print “Getting messages”
messages = droid.smsGetMessages(False,’inbox’).result

my_uri= ‘content://com.android.contacts/data/phones’
print “Trying droid.queryContent”
contacts = droid.queryContent(my_uri,None,None,None,None).result

fn =”contacts.pickle”
f = open(fn,’w’)
pickle.dump(contacts,f)
f.close()

fn = “msgs.pickle”
f = open(fn,’w’)
pickle.dump(messages,f)
f.close()

But there’s apparently a bug in my version which returns integers rather than actual email addresses etc

All up, including time refamiliarising myself with adb, installing sl4a and python for android this took about 90 minutes.  I would have spent at least this amount of time trawling through useless apps on (the, now, particularly awful) Google Play. Once I marry up these data sets and verify them a little I will delete my SMSs and get on with things.

Of course, after all that I find (by serendipity) that someone has already done it.

Google is increasingly becoming useless as a search engine

Update (next day)

HTC Desire seems unable to delete an entire thread or at least one with thousands of SMSs.  I suspect that it is something to do with the suspend timing.  Since its not finishing the whole deletion, none of the SMSs get deleted.

Anyway, I am doing that manually as well – it is quite slow – deleting 100 took 300ish seconds – 3 seconds each!  Java would presumably be faster? The rate per delete goes down with the number of messages in the database (to about 1 second per delete).  Presumably this release of Android does something dumb like compacts the database after each delete?

So, 24 hours later and I am 5000 ish SMSs lighter.

About these ads

0 Responses to “Backing up SMS on HTC Desire (Android)”



  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




Blog Stats

  • 152,590 hits

OSWALD Newsletter

If you would like to receive OSWALD, a weekly open source news digest please send an email to oswald (with the subject "subscribe") at opensourcelaw.biz

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: