Document directory
- I. Overview of Storage Methods
- Ii. Detailed introduction
- Iii. Applicable scenarios of various methods
Scope of discussion: The SDK between windowsphone8 is released soon. Due to the article's validity, We need to describe that this article only discusses the data storage method under Windows Phone 7, but I think the content is also applicable to windowsphone8, windowsphone8 will bring about a new data storage method.
I. Overview of Storage Methods
- Files in the local project: the files are compiled into resource or content ).
- Independent Storage)
- Local Database
- Web Service/WCF
- Cloud/azure
Ii. Detailed introduction
1. Local project files
You can set the file generation method (buildaction) (Resource) Is compiled into binary code. The advantage is that it can be used at any time, but it may lead to slow loading at startup. In the code, you can use application. getresourcestream to read data. These scenarios are generally used: do not consider the startup time of the program; Do not update the resource file (because the project is compiled, do not count on it); reduce program dependencies.
You can set the file generation method (buildaction) (ContentIs compiled into the project file, but not in the binary code. The advantage is high efficiency and can be shared by multiple packages. In the code, you can use xelement. Load to read data. These scenarios are generally used: Consider the startup time of the program; update the resource file (don't expect it because it is compiled into the project ).
2. Independent Storage
If you want to store user data, you can use independent storage. In Silverlight and windowsphon, there is no interface for directly storing system files, but you can use independent storage to store your data on your devices. You can use key-value pairs (isolatedstoragesettings class) or files (isolatedstoragefile class)
3. Local Database
Sqlce: the format of your own portable database (only available in 7.1)
SQLite: a third-party portable database format.
Through my actual use, I found that the multi-thread read/write processing is not very good, and it is easy to be abnormal. Of course, I may not have a deep understanding of its features.
4. Web Service
There may be the following formats:
Rest, pox, JSON, odata, and soap.
There are also the following access methods:
HTTP: You can directly use the httpwebrequest or WebClient class to call WebService and send a request to WebService through the HTTP protocol to obtain returned data in XML or JSON format.
Reference WCF Service: in fact, WCF is a WebService framework that supports multiple protocols (including HTTP and TCP) and multiple formats (soap, XML, atom)
Using the odata client: it is also called the WCF data service, formerly called the ADO. NET data service. It is a framework for accessing existing data in the form of rset. The WCF Data Service provides odata format data. For example, when windowsphone interacts with Sharepoint, Sharepoint provides the WCF data service, and the WCF data service processes all HTTP interactions, serialization, and other tasks, this means that the app can directly perform callback deletion and modification on remote data through the HTTP protocol, even cross-origin. The odata for windowsphone client may be found on codeplex
5. Azure
You can also use Windows azure to access data, but the free service is limited. Azure provides persistent data storage on ECS, and the operation method is similar to WebService.
Iii. Applicable scenarios of various methods
Compile the resource source file |
Embed read-only data into a binary Program |
Compile it into a Content File |
Update data without recompilation |
Independent Storage |
Access user information |
HTTP class |
Use third-party rest or pox services to access data |
HTTP class |
Get RSS subscriptions |
Use proxy-class WCF |
Store data from the soap Service |
WCF |
Publish existing classes as services from Silverlight |
Odata |
Access odata |
Azure |
Store large amounts of data |
|
|