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:

Here's the code of the script above:

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)) {
			$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());
	} 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:

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


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.


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

How do I download it?