WP7 independent storage

Source: Internet
Author: User

There are roughly three types: settings, files/folders, and relation data.

MSD recommendations on Thread Synchronization:

To synchronize access to isolated storage between different threads, we recommend using the system. threading. mutex class. A mutex grants exclusive access to a shared resource to only one thread. if one thread acquires a mutex, the second thread that wants to acquire that mutex is suincluded until the first thread releases the mutex. for example, A mutex cocould be used to synchronize access to an isolated storage folder between a Windows Phone application running in the foreground and a background agent.

1. folders of special use:

In addition to the custom system, you have created some folders for special purposes :'

Path

Use

Notes

Shared

Used to hostMedia,Shellcontent, AndTransfersFolders.

This folder is created when your application is installed, but it can be deleted.

Shared/Media

Album Art: Applications can use this folder to display album art in the universal volume control (UVC) while playing background audio.

This folder is created when your application is installed, but it can be deleted. For more information, seeHow to: integrate with the music and videos hub for Windows Phone.

Shared/shellcontent

Application tiles: Tiles can display background images on the front and back of each tile. Background images can be stored in isolated storage, but must be located in this folder or a subfolder of it.

This folder is created when your application is installed, but it can be deleted. For more information, seeTiles overview for Windows Phone.

Shared/transfers

Background File Transfer: Applications can save files to isolated storage in the background, even when the application is no longer running in the foreground.

This folder is created when your application is installed, but it can be deleted. For more information, seeBackground file transfers overview for Windows Phone.

2. View independently stored content

2. 1. Microsoft SDK provides: Use isolated storage explorer (isw.l.exe), to list, copy, and replace files and directories in isolated storage in a Windows Phone application. isolated storage Explorer is a command-line tool that gets installed with Windows Phone SDK 7.1. this tool enables you to verify that files are being saved in the correct location with the correct data. isolated storage Explorer can be used in the emulator or a device. for more information, seeHow to: Use the isolated storage explorer tool.

2.2 some visualization tools developed by users

Http://blogs.msdn.com/ B /mikeormond/archive/2011/09/01/free-gui-isolated-storage-explorer-tool.aspx

3. DetailsCode

3.1 create settings page

 
IsolatedstoragesettingsClass

The http://msdn.microsoft.com/en-us/library/system.io.isolatedstorage.isolatedstoragesettings (vs.95). aspx

 
Isolatedstoragesettings settings = isolatedstoragesettings. applicationsettings; settings. add (Key, value); settings [Key] = value; If (settings. contains (key) {value = (t) settings [Key];}

Note that data is not immediately executed to an independent storage. msdn:

Data written toIsolatedstoragesettingsObject is saved when the application that uses the class is closed. this can occur when the user closes the web browser, refreshes a page, or browses away from the page. if you want your application to write to isolated storage immediately, you can callSaveMethod in application code.

IfIsolatedstoragefileDoes not have enough available free space to save your application settings,IsolatedstorageexceptionWill be thrown. If more space is required, useIsolatedstoragefile.IncreasequotatoMethod to request more storage space from the host.

2. files and folders

// Create a folder and myfile.txt to write a text clip. Isolatedstoragefile mystore = isolatedstoragefile. getuserstoreforapplication (); // create a new folder and call it "myfolder ". mystore. createdirectory ("myfolder"); // specify the file path and options. using (VAR isofilestream = new isolatedstoragefilestream ("myfolder \ myfile.txt", filemode. openorcreate, mystore) {// write the data using (VAR isofilewriter = new streamwriter (isofilestream) {isofilewriter. writeline (txtwrite. text) ;}}// read the text out of isolatedstoragefile mystore = isolatedstoragefile. getuserstoreforapplication (); try {// specify the file path and options. using (VAR isofilestream = new isolatedstoragefilestream ("myfolder \ myfile.txt", filemode. open, mystore) {// read the data. using (VAR isofilereader = new streamreader (isofilestream) {txtread. TEXT = isofilereader. readline () ;}} catch {// handle the case when the user attempts to click the read button first. txtread. TEXT = "need to create directory and the file first. ";}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.