How to copy text messages from your iPhone to an Android device

So you've given up waiting for iTunes to do a full sync of your phone and bought yourself an Android phone. Bringing over your email and contacts is a doddle because you're using Gmail, right?

Text messages however are a little trickier.

First you'll need to do an iPhone backup (if you haven't done so recently), then find the file 3d0d7e5fb2ce288813306e4d4636395e047a3d28 with the extension .mdbackup or .mddata in your iTunes backup folder.

This file is a SQLite database, and needs to be converted to XML format and here's the script to do it:

http://semplicewebsites.com/sms.php

Here's the code of the script above:

<?php
if(isset($_FILES['file'])) {
	$db = new SQLite3($_FILES['file']['tmp_name']);
	if(($result = @$db->query('SELECT * FROM message'))) {
		$smses = new SimpleXMLElement('<smses></smses>');
		$i = 0;
		while($row = $result->fetchArray(SQLITE_ASSOC)) {
			$i++;
			$sms = $smses->addChild('sms');
			$sms->addAttribute('protocol', 0);
			$sms->addAttribute('address', $row['address']);
			$sms->addAttribute('date', $row['date'] * 1000);
			$sms->addAttribute('type', $row['flags'] == 3 ? 2 : 1);
			$sms->addAttribute('subject', '');
			$sms->addAttribute('body', $row['text']);
			$sms->addAttribute('toa', $row['flags'] == 3 ? 0 : 145);
			$sms->addAttribute('sc_toa', 0);
			$sms->addAttribute('service_center', 'null');
			$sms->addAttribute('read', 1);
			$sms->addAttribute('status', -1);
		}
 
		$smses->addAttribute('count', $i);
 
		header('Content-type: text/xml');
		header('Content-Disposition: attachment; filename="sms.xml"');
		echo str_replace('<sms', "\r\n<sms", $smses->asXML());
		die();
	} else {
		echo "There was a problem opening your SMS file.<br />";
	}
}
?>

Now that you have your sms.xml file, you'll need to install this free Android app:
https://market.android.com/details?id=com.riteshsahu.SMSBackupRestore

Once installed, copy the sms.xml to the SMSBackup folder on your SD card, fire up the app and hit restore!

Comments

Thank you for this how-to guide. A big help for users like me who does not have time to experiment and do trial-and-error.

Thanks

can you converted this file to XML android please ???

How do I download it?