2014-04-27 62 views
0

我需要存儲一些數據以用於基於Windows8的移動應用程序。數據需要重用。舉個例子,需要存儲4個電話號碼來發送消息,另外一個發送呼叫。我如何在這裏存儲數據。我聽說過隔離存儲。這是否可以將它連接到數據庫?如果連接到數據庫,它的應用程序是否會太重?存儲在移動應用程序中的數據(Windows 8)

回答

0

不確定連接到數據庫的含義。

在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

獨立存儲將允許您永久存儲文件並檢索它,即使用戶退出其應用程序。

相關問題