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?
Asked
Active
Viewed 112 times
0
-
what kind of data are you storing? (configuration like xml / text) or binary (pictures, audio) ? – flo scheiwiller Mar 19 '14 at 10:41
-
I want to store text/strings – Patrick Jore Mar 19 '14 at 10:43
-
How many strings? There is no "best" way. It might be to put them in a database, or store in file, or realize that you may not have enough that it matters. – WiredPrairie Mar 19 '14 at 10:50
-
Use static type to implement cache – Jaihind Mar 19 '14 at 10:57
1 Answers
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
-
1Yes 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
-
1A 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