1. redbullqwe's Avatar
    Hi,

    I'm fairly new to windows phone programming.

    I need to store data on the phone when the app closes, and load the data when the app starts.

    Specificly BitmapImages, dictionaries of all types and simple integers, bool etc.

    At the moment i have implemented a different method for every different type of data, that converts the dictionary to json, and then saves it as a .json file on the phone.

    BitmapImages are of course not converted to json, they are saved in the way described in the WP documentary.

    This technique is very painful, because every time I need to save data thats of a new type, i have to implement a method for that first.

    Now my question, do you know any way to accomplish this task, thats more robust and flexible than mine?

    I found an article about a local database on WP here and I'm now experimenting a bit with that, but I'm not sure if it can really do what I want.

    I would really appreciate any help, because I have been stuck with this task a long time now ;)
    04-05-2013 03:32 AM
  2. WesternLights's Avatar
    Personally I make my custom classes serializable with [DataContract] keywords and save them using IsolatedStorageSettings. It seemed much easier to me than a local actual database. Example from my cPlayer application:

    Code:
        [DataContract]
        [KnownType(typeof(RootItem))]
        [KnownType(typeof(MediaServerItem))]
        [KnownType(typeof(FolderItem))]
        [KnownType(typeof(MovieItem))]
        [KnownType(typeof(SubtitlesItem))]
        [KnownType(typeof(UnknownFileItem))]
        public abstract class FileSystemItem : INotifyPropertyChanged
        {
            [DataMember]
            public string _icon;
            [DataMember]
            public string _iconpath = "Resources/Icons/";
            [DataMember]
            public string guid = "";
            [DataMember]
            public string _title;
            [DataMember]
            public string _titlelower;
            [DataMember]
            public string _parentid;
            [DataMember]
            public string _id;
            [DataMember]
            public string _type;
            [DataMember]
            public string _actionurl;
            [DataMember]
            public bool _showcheckbox = false;
            [DataMember]
            public bool _selected = false;
            [DataMember]
            public string _information;
            [DataMember]
            public DateTime _lastplayed;
            [DataMember]
            public int _filesize;
            [DataMember]
            public List<SubtitlesItem> Subs { get; set; }
    
            //below are methods, they don't need to be seralized
    
        }
    Instances of the above class are saved in IsolatedStorageSettings. RootItem, MediaServerItem, FolderItem, MovieItem, SubtitlesItem, UnknownFileItem are subclasses of FileSystemItem.
    04-05-2013 12:09 PM

Similar Threads

  1. Working with local database in background agent
    By vunder in forum Software Development and Hacking
    Replies: 0
    Last Post: 04-13-2012, 04:41 AM
  2. Xbox Live Leaderboards only show local score?
    By seaniccus in forum Windows Phone 7
    Replies: 1
    Last Post: 01-21-2011, 07:43 PM
  3. Bing Local search fix (outside the US)
    By fc000 in forum Windows Phone 7
    Replies: 1
    Last Post: 12-15-2010, 11:30 AM
LINK TO POST COPIED TO CLIPBOARD