0
我需要存储一些数据以用于基于Windows8的移动应用程序。数据需要重用。举个例子,需要存储4个电话号码来发送消息,另外一个发送呼叫。我如何在这里存储数据。我听说过隔离存储。这是否可以将它连接到数据库?如果连接到数据库,它的应用程序是否会太重?存储在移动应用程序中的数据(Windows 8)
我需要存储一些数据以用于基于Windows8的移动应用程序。数据需要重用。举个例子,需要存储4个电话号码来发送消息,另外一个发送呼叫。我如何在这里存储数据。我听说过隔离存储。这是否可以将它连接到数据库?如果连接到数据库,它的应用程序是否会太重?存储在移动应用程序中的数据(Windows 8)
不确定连接到数据库的含义。
在Windows Phone 8中,独立存储是指每个应用程序在手机上存储的内容,我不认为其他应用程序可以访问它。基本上如果你需要保存的东西看起来就像那样。 下面的代码保存的东西:
IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication();
//create new file
using (StreamWriter writeFile = new StreamWriter(new IsolatedStorageFileStream("myFile.txt", FileMode.Create, FileAccess.Write, myIsolatedStorage)))
{
string someTextData = "This is some text data to be saved in a new text file in the IsolatedStorage!";
writeFile.WriteLine(someTextData);
writeFile.Close();
}
要访问文件随时你只是这样做:
IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication();
IsolatedStorageFileStream fileStream = myIsolatedStorage.OpenFile("myFile.txt", FileMode.Open, FileAccess.Read);
using (StreamReader reader = new StreamReader(fileStream))
{ //Visualize the text data in a TextBlock text
this.text.Text = reader.ReadLine();
}
这里是链接。 http://www.geekchamp.com/tips/all-about-wp7-isolated-storage-read-and-save-text-files
独立存储将允许您永久存储文件并检索它,即使用户退出其应用程序。