0

I am making a app in windows phone sdk 8 and I was wondering what the best method is to store local data. I want to use this for storing data and optimize memory usage. Can someone help me with this?

Patrick Jore
  • 43
  • 1
  • 7

1 Answers1

0

If you want to store strings then you can use IsolatedStorageSettings

Basically the easiest way to put data into WP7 IsolatedStorage is to use the IsolatedStorageSettings class which is a Dictionary that stores key-value pairs in isolated storage.

Sample storage and retrieval

//storage
IsolatedStorageSettings.ApplicationSettings["State"] = your string;
 IsolatedStorageSettings.ApplicationSettings.Save();

//retrieval
 if (IsolatedStorageSettings.ApplicationSettings.Contains("State") == true)
 {
 var object= IsolatedStorageSettings.ApplicationSettings["State"] as string;
 //Remove the state now
 IsolatedStorageSettings.ApplicationSettings.Remove("State");
 IsolatedStorageSettings.ApplicationSettings.Save();
 }

also, just check this link

A.K.
  • 3,321
  • 1
  • 15
  • 27
  • Isolated settings really isn't a cache, and may introduce other performance issues and use disk space unnecessarily unless it is properly managed. – WiredPrairie Mar 19 '14 at 10:51
  • 1
    Yes it is not the best way, probably the best way to store could be keeping it inside database or making a file and then storing it. But, what if there is only a single string? – A.K. Mar 19 '14 at 10:56
  • 1
    A single string or even a reasonable number could be easily cached in a Dictionary. The question is at least partly about a cache given the title, not persistent storage. – WiredPrairie Mar 19 '14 at 10:58