locked
Windows.Storage.ApplicationData.current.roamingSettings does not store more than 4K data RRS feed

  • Question

  • Windows.Storage.ApplicationData.current.roamingSettings does not store more than 4K data.

    I wrote s small snippet for storing data in roaming settings:

                for (var i = 0; i < 10000; i++) {
                    value += "def";
                    Windows.Storage.ApplicationData.current.roamingSettings.values.insert("testKey", value )
                }

    However this always failed when the size of the value string exceeded 4000 bytes

    Saturday, February 16, 2013 3:02 AM

Answers

  • The individual settings in the composite are still limited to 8000KB. The composited setting is limited to 64KB for all of its combined values.

    If you need to store as much data as you are talking about here then I'd recommend saving it to a file rather than as a setting.

    --Rob

    • Marked as answer by Song Tian Friday, February 22, 2013 10:12 AM
    Sunday, February 17, 2013 1:23 AM
    Moderator

All replies

  • Is it failing at 4000 bytes or at 4000 characters (which is 8000 bytes)? Remember that in the UTF-16 encoding each character is 2 bytes.

    As documented, a single setting is limited to 8000 bytes.

    --Rob

    Saturday, February 16, 2013 3:16 AM
    Moderator
  • Thanks Rob.

    The documentation also mentions that each composite settings can store upto 64K of data. Is there any code snippet which you can point me at for using composite settings.

    Also are local settings, roaming settings, and composite settings are 3 distinct and different application settings container in which data can be stored ?

    Saturday, February 16, 2013 4:16 AM
  • There's a composite settings code snippet in  Quickstart: Roaming app data and more complete sample in the Application data sample .

    Local settings and roaming settings are separate. Composite settings are a type of setting which can be stored in either the local or roaming setting stores.

    --Rob

    Saturday, February 16, 2013 4:28 AM
    Moderator
  • Hi Rob,

    The documentation (http://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.applicationdata.roamingsettings.aspx) states that each composite setting can store upto 64K of data. However local/roaming settings store can store only 8K of data (per setting). I do not understand how can composite settings can be stored in local/roaming settings store (i.e. 64K of data in 8K of data store). I am misunderstanding something ?

    Saturday, February 16, 2013 4:39 AM
  • Simple settings can be up to 8K.
    Composite settings can be up to 64K.

    They are stored differently and so have different limitations. A composite setting isn't just stuffed into a normal setting's slot, even though they both are added to the container in essentially the same way.

    --Rob

    Saturday, February 16, 2013 5:15 AM
    Moderator
  • Hi Rob,

    I wrote the following code snippet:

                var composite = new Windows.Storage.ApplicationDataCompositeValue();

                var test = "abc";
                for (var i = 0; i < 700; i++) {
                    test += "aaaaaa";

                }

                composite["intVal"] = test;

                Windows.Storage.ApplicationData.current.roamingSettings.values.insert("testKey", composite);

    But again the code failed at

    composite["intVal"] = test;

    when size of test string exceeded 4000 characters (or 8KB assuming 2 bytes per character)

    Not sure why am I always failing at 8K limit and not able to utilize the complete 64K limit

    Saturday, February 16, 2013 5:13 PM
  • The individual settings in the composite are still limited to 8000KB. The composited setting is limited to 64KB for all of its combined values.

    If you need to store as much data as you are talking about here then I'd recommend saving it to a file rather than as a setting.

    --Rob

    • Marked as answer by Song Tian Friday, February 22, 2013 10:12 AM
    Sunday, February 17, 2013 1:23 AM
    Moderator