windows phone應用設定容器物件ApplicationDataContainer

來源:互聯網
上載者:User

標籤:style   blog   io   color   os   使用   sp   資料   div   

應用設定是windows phone中封裝好的資料存放區方式,是儲存在應用程式儲存區的索引值對集合,它自動序列化對象,並將其儲存在應用程式裡面。

當應用程式刪除時,儲存的資料也會隨之消失,此種方式主要儲存一些應用程式設定資訊。

基本特點:

1、應用程式設定擁有容器的階層,因此容器裡面還可以在嵌套容器,容器最多可以嵌套32層。

2、應用程式設定所儲存的是單個的資料類型對象。

使用方法:

1、擷取本地應用程式設定容器:

 ApplicationDataContainer _appSetting = ApplicationData.Current.LocalSettings;

2、添加和修改應該設定 

   _appSetting.Values["keys"] = "wp學習中";

注意:如果不存在鍵則新增一個,如果已經有鍵,則對原來的值進行修改。

3、讀取應該設定

 string values = _appSetting.Values[keys].ToString();

4、刪除應用設定

   _appSetting.Values.Remove("keys");

設定存在容器:

//如果容器不存在則建立ApplicationDataContainer container = _appSetting.CreateContainer("NewContainer", ApplicationDataCreateDisposition.Always);

刪除容器

  _appSetting.DeleteContainer("NewContainer");

在新容器上添加資訊

            //判斷容器是否存在            if (_appSetting.Containers.ContainsKey("NewContainer"))            {                _appSetting.Containers["NewContainer"].Values["keys"] = "hello wp";            }

刪除容器上的資訊

           if (_appSetting.Containers.ContainsKey("NewContainer"))            {                _appSetting.Containers["NewContainer"].Values.Remove("keys");            }

 

windows phone應用設定容器物件ApplicationDataContainer

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.