Migrating SMSes from Nokia to Android

My wife recently got a Samsung Exhibit II 4G Android phone to replace her aging Nokia E63. Migrating her contacts was accomplished fairly easily by exporting them to CSV with Nokia PC Suite and then importing them into Google Contacts. Migrating SMSes was not so trivial however.

Other approaches

There are a couple methods floating around the web, but none were suitable. This one uses Gammu to retrieve the SMSes from the Nokia, and then a script to convert them to an XML format readable by SMS Backup & Restore. It turns out that Gammu doesn't work on Symbian S60v3 devices however. This script can convert SMSes exported by the MsgExport app to XML for SMS Backup & Restore, but I didn't feel like paying for it or dealing with the Ovi Store. VeryAndroid is a Windows application which can convert SMSes from Nokia PC Suite CSV format and sync them directly to an Android device, and Nokia2AndroidSMS can convert SMSes from the OVI Suite database to XML for SMS Backup & Restore. I didn't want to deal with more Windows software though, so I just decided to write my own.

Formats

I already had the Nokia PC Suite installed and was using it to migrate contacts, so I decided to work with the CSV output it generates for messages. A received SMS looks like this:

sms,deliver,"+16501234567","","","2012.06.13 19:13","","Leaving now"

and a sent SMS looks like this:

sms,submit,"","+16501234567","","2012.06.13 19:11","","Where are you?"

The fields are:

  • 0: "sms" for SMSes (MMS is presumably different)
  • 1: "deliver" for received messages, "submit" for sent messages
  • 2: Sender's phone number (blank for sent messages)
  • 3: Recipient's phone number (blank for received messages)
  • 5: Date and time in "YYYY.MM.DD HH:MM" format and local timezone
  • 7: Message body

Fields 4 and 6 are always empty for SMSes (they are probably used for MMSes, one being the message subject).

I also decided to generate XML for the SMS Backup & Restore app. The XML format looks like this:

<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
<?xml-stylesheet type="text/xsl" href="sms.xsl"?>
<smses count="1">
  <sms
    protocol="0"
    address="+16501234567"
    date="1341025384351"
    type="1"
    subject="null"
    body="Leaving now"
    toa="null"
    sc_toa="null"
    service_center="+12063130025"
    read="1"
    status="-1"
    locked="0"
    date_sent="null"
    readable_date="Jun 29, 2012 8:03:04 PM"
    contact_name="(Unknown)"
  />
</smses>

but can be reduced down to this:

<?xml version="1.0" encoding="UTF-8"?>
<smses count="1">
    <sms
        protocol="0"
        address="+16501234567"
        date="1341025384351"
        type="1"
        body="Leaving now"
        read="1"
        status="-1"
    />
</smses>

The attributes of the <sms> element are:

  • protocol: Always "0" (possibly different for MMS)
  • address: Sender or recipient phone number
  • date: Date and time in milliseconds since 1 January 1970
  • type: "1" for received message, "2" for sent messages
  • body: Message body
  • read: "1" if the message has been read
  • status: Always "-1"

The script

I implemented a script called [nokia2android.py] in [Python] to convert one or more CSV files to this XML format.

./nokia2android.py received.csv sent.csv > android.xml

The XML file can then be transferred to the Android device (using USB or Bluetooth) and stored in /sdcard/SMSBackupRestore. It will then be presented as an option after selecting the Restore button in the app.

Trackback URL for this post:

http://michael.gorven.za.net/trackback/1494
AttachmentSize
nokia2android.py.txt1.15 KB

Hi Michael, thanks for the

Hi Michael,

thanks for the script. I have a problem, the script builds the following datastructure:

< sms address="+123456" body="Hi how are you" date="1384593960000" protocol="0" read="1" status="-1" type="1"/>

I used your script and didn't modify anything. Do you know why the order is changed?

Sadly until now SMS-Backup is not importing my data.

Greetings

Hi! You seem to be migrating

Hi! You seem to be migrating to Blackberry -- my script is for migration to Android. The Blackberry app you mentioned doesn't seem related to the Android one, and so probably doesn't support the format my script converts to.

Hi, thanks for your fast

Hi,

thanks for your fast response. I think its the same because if I do a backup on my mobile, the generated xml is the same. I thought that maybe the different order of the items may cause the problem. So maybe I should write to the coder and ask him.

thanks

I'm really enjoying the

I'm really enjoying the design and layout of your blog.
It's a very easy on the eyes which makes it much more enjoyable for me to come
here and visit more often. Did you hire out a designer to create your theme?
Exceptional work!

The order of attributes in an

The order of attributes in an XML element is supposed to be irrelevant, so that's unlikely to be an issue.

Please let me know if you're

Please let me know if you're looking for a article author for your weblog.

You have some really good posts and I think I would be a good asset.

If you ever want to take some of the load off, I'd love to write some
articles for your blog in exchange for a link back
to mine. Please blast me an e-mail if interested. Thanks!

Hi Michael, thanks for your

Hi Michael,

thanks for your reply. I was also wondering, but I asked the developer and he told me, that he uses an additional variable. I had to add 'contact_name="(Unknown)"'. So now everything went fine. Thanks for your script, it helped me a lot.

Greetings

Awesome, glad it helped!

Awesome, glad it helped!

Pingback

[...] post:  Migrating SMSes from Nokia to Android | Michael Gorven … This entry was posted in Uncategorized and tagged archives, backup, coding, friendfeed, [...]