Android developer _ backup SMS and android development backup
Zookeeper
Principles of text message backup
The principle of text message backup is to use the content provider to read and save the text message.
Public class SmsBackupUtils {// callback interface public interface SmsBackupCallback {/*** total number of messages called * @ param total text messages */public void beforeSmsbackup (int total) before SMS backup ); /*** call * @ param progress SMS progress */public void progressSmsbackup (int progress);}/*** to back up the SMS, back up the file to an xml file because the xml file is highly cross-platform. This is a time-consuming operation, it should be placed in the Child thread to execute ** @ param context Context * @ param path which path to back up * @ throws Exception */public static void smsBackup (context, String path, SmsBackupCallback callBack) throws Exception {// xml serializer XmlSerializer serializer = Xml. newSerializer (); File file = new File (path); FileOutputStream fos = new FileOutputStream (file); // you can specify the serializer parameter. setOutput (fos, "UTF-8"); // start serializer. startDocument ("UTF-8", true); serializer. startTag (null, "smss"); ContentResolver resolver = context. getContentResolver (); Uri uri = Uri. parse ("content: // sms"); // contains all sms Cursor cursor = resolver. query (uri, new String [] {"address", "date", "type", "body"}, null);/* dialog. setMax (cursor. getCount (); progressBar1.setMax (cursor. getCount (); */callBack. beforeSmsbackup (cursor. getCount (); int progress = 0; while (cursor. moveToNext () {serializer. startTag (null, "sms"); serializer. startTag (null, "address"); String address = cursor. getString (0); serializer. text (address); serializer. endTag (null, "address"); serializer. startTag (null, "date"); String date = cursor. getString (1); serializer. text (date); serializer. endTag (null, "date"); serializer. startTag (null, "type"); String type = cursor. getString (2); serializer. text (type); serializer. endTag (null, "type"); serializer. startTag (null, "body"); String body = cursor. getString (3); serializer. text (body); serializer. endTag (null, "body"); serializer. endTag (null, "sms"); progress ++;/* dialog. setProgress (progress); progressBar1.setProgress (progress); */callBack. progressSmsbackup (progress); SystemClock. sleep (1000);} cursor. close (); serializer. endTag (null, "smss"); serializer. endDocument ();}}
Where is the android text message backup?
Is the imported and exported text message provided? If yes, back up the file in the memory card. SmsBackup folder.
How does android back up text messages?
STEP/Method
1. Press "Menu" in "information" and select "Settings ".
2. Select the settings in the information.
Pull the "Settings" page to the bottom, and there are four options in the Backup Settings.
Export SMS
Import SMS
Back up SMS/MMS data
Restore SMS/MMS data
3. Export SMS: Back up the SMS directly to the SD card
4. Text message import: directly import the text message backed up previously from the SD card
5. Back up SMS/MMS data: backs up both SMS and MMS data to the SD card (only one backup is supported, and the latest backup will directly overwrite the original backup)
Restore SMS/MMS data: Restore the previously backed up data directly from the SD card (restart the mobile phone after the backup is complete)