Android combat tutorial Chapter 8 SMS Backup

SMS Backup is included in all kinds of mobile assistant. The function of SMS mainly includes four items: content body, event date, method type and number address. SMS Backup ~ 1. Use a stupid way to save SMS to XML file and save it in external storage. There will be: SMS Backup ~ 2 (XML serializer); SMS Backup ~ 3 (content provider obtains SMS XML backup); SMS Backup ~ 4 (backup database SMS in JSON mode). Backup methods are becoming more and more efficient. Compare different storage methods.

Obviously, the first introduction of SMS Backup, in a simple and clumsy way, does not involve content providers, virtual 10 SMS.

SMS should be saved in the form of object. So create a JavaBean class:

Next, in the mainactivity Code:

Because it involves writing to the SD card, remember to add permissions in the list file:

Run the program and click the SMS Backup button. Export XML file on SD card and open it with browser. That is, the backup of all SMS information. However, this method is very clumsy, and when there is a < body > tag in the user's SMS message, the last < body > has no tail node to match it. An error will be reported, and the browser cannot parse this file. This way will not be used. Knowledge provides an idea. This problem will not be encountered if we first introduce the generation of XML files by XML serializer.

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>