logo
down
shadow

How to save IsolatedStorageSettings key to a string


How to save IsolatedStorageSettings key to a string

By : vanous
Date : November 17 2020, 04:28 AM
it helps some times I'm making a project for windows phone 8 using C# and I want to be able to save some strings to storage so the next time the user opens the app, He'll be able to have the strings he saved last time he opened it.
code :
if (IsolatedStorageSettings.ApplicationSettings.Contains("key") && 
        IsolatedStorageSettings.ApplicationSettings["key"] != null)
{
    string GetKey = IsolatedStorageSettings.ApplicationSettings["key"].ToString();
}


Share : facebook icon twitter icon
windows phone 7 + IsolatedStorageSettings + Add and Save function

windows phone 7 + IsolatedStorageSettings + Add and Save function


By : Renan Andrade
Date : March 29 2020, 07:55 AM
will be helpful for those in need .Save() actually persists the isolated storage settings instance (such as ApplicationSettings) to the media (e.g. phone storage).
This is automatically done when your application is tombestoned (_Deactivated) or closed (_Closed). That is why you get same value without even calling save.
Unable to Save IsolatedStorageSettings.ApplicationSettings for wp7

Unable to Save IsolatedStorageSettings.ApplicationSettings for wp7


By : Sarika Viswanath
Date : March 29 2020, 07:55 AM
This might help you Add the attribute [DataMember] on all properties that you want to serialize in your MyDetailsObject class.
Save List to IsolatedStorageSettings

Save List to IsolatedStorageSettings


By : Kiran Kumar
Date : March 29 2020, 07:55 AM
I wish did fix the issue. You can't serialize a private class in the ApplicationSettings. Declare it as public instead:
code :
public class LyricsItem
{
    public LyricsItem()
    {

    }

    public LyricsItem(LyricsItem item)
    {
        this.searchUrl = item.searchUrl;
        this.croppingRegex = item.croppingRegex;
    }

    private string _searchUrl;
    private string _croppingRegex;

    public string searchUrl
    {
        get { return _searchUrl; }
        set { _searchUrl = value; }
    }

    public string croppingRegex
    {
        get { return _croppingRegex; }
        set { _croppingRegex = value; }
    }
}
The IsolatedStorageSettings.Save method in Windows Phone: does it save the whole dictionary?

The IsolatedStorageSettings.Save method in Windows Phone: does it save the whole dictionary?


By : Mark Pasquantonio
Date : March 29 2020, 07:55 AM
This might help you I've managed to find the implementation of the IsolatedStorageSettings.Save method in the entrails of the Windows Phone emulator VHD images supplied with the Windows Phone SDK (the answer to this question on SO helped me to do that). Here is the source code of the method:
code :
public void Save()
{
    lock (this.m_lock)
    {
        using (IsolatedStorageFileStream isolatedStorageFileStream = this._appStore.OpenFile(this.LocalSettingsPath, 4))
        {
            using (MemoryStream memoryStream = new MemoryStream())
            {
                Dictionary<Type, bool> dictionary = new Dictionary<Type, bool>();
                StringBuilder stringBuilder = new StringBuilder();
                using (Dictionary<string, object>.ValueCollection.Enumerator enumerator = this._settings.get_Values().GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        object current = enumerator.get_Current();
                        if (current != null)
                        {
                            Type type = current.GetType();
                            if (!type.get_IsPrimitive() && type != typeof(string))
                            {
                                dictionary.set_Item(type, true);
                                if (stringBuilder.get_Length() > 0)
                                {
                                    stringBuilder.Append('\0');
                                }
                                stringBuilder.Append(type.get_AssemblyQualifiedName());
                            }
                        }
                    }
                }
                stringBuilder.Append(Environment.get_NewLine());
                byte[] bytes = Encoding.get_UTF8().GetBytes(stringBuilder.ToString());
                memoryStream.Write(bytes, 0, bytes.Length);
                DataContractSerializer dataContractSerializer = new DataContractSerializer(typeof(Dictionary<string, object>), dictionary.get_Keys());
                dataContractSerializer.WriteObject(memoryStream, this._settings);
                if (memoryStream.get_Length() > this._appStore.get_AvailableFreeSpace() + isolatedStorageFileStream.get_Length())
                {
                    throw new IsolatedStorageException(Resx.GetString("IsolatedStorageSettings_NotEnoughSpace"));
                }
                isolatedStorageFileStream.SetLength(0L);
                byte[] array = memoryStream.ToArray();
                isolatedStorageFileStream.Write(array, 0, array.Length);
            }
        }
    }
}
Isolatedstoragesettings.applicationsettings.save does not save

Isolatedstoragesettings.applicationsettings.save does not save


By : lu Bu
Date : March 29 2020, 07:55 AM
this one helps. If you are saving ONLY when the app is closing (i.e. Application_Closing), then you are not capturing the state often enough. Depending upon how you have exited the app, there are times when the application is simply deactivated, but not necessarily closed. If the app is subsequently tombstoned after deactivation, you will have needed to save the state appropriately to restore it back.
Here is an article to give you a better idea of the different states.
Related Posts Related Posts :
  • Can I organize Git submodules in a flat hierarchy?
  • How to make a server reply after receiving a request/data
  • Stored Procedure works in DB but not in C# code
  • MVVM WPF Programmatically add Child Elements
  • NCrunch and PostSharp Logging clash
  • Increasing memory usage in socket client
  • Multiple DropDownList but same action
  • How to get application memory usage as shown in Task Manager?
  • Exposing interfaces instead of concrete classes
  • How to get only postal_code data from google api?
  • Is there a way to get rid of the (by dot42) using community licence?
  • Why must I implement a function for an interface in vb.net which apparently doesn't need to be implemented in C#
  • How to remove HTML tags from the gridview Row
  • Get public post from Facebook's Graph Search API 2.x with Facebook SDK for .NET
  • C# DLL Export to Inno-Setup - Error E0434F4D
  • syntax error insert into database
  • By-pass else block of int.TryParse in Lambda Syntax
  • Retrieve "property getter" from the property name
  • Implementing generic class and multiple interfaces
  • data bind DropDownList with OleDbDataReader from Ms access 2013
  • extract specific data from HTML -CDATA- pattern in C#
  • how to compare password with salted hashed password
  • Excluding one item from list (by Index), and take all others
  • How do I find out which argument is invalid when receiving 'The best overloaded match for (...) has some invalid argumen
  • How do I use a linq query to update the underlying database table
  • How to change the coordinates of a text in a pdf page from lower left to upper left
  • Entity Framework Error: error loading specified metadata resource
  • Writing one character at a time in a C# Console Application?
  • Read write barcode data without using barcode scanner device
  • Asp.net Website is only accessible on our company internet connection and not from other network
  • Generic method to map objects of different types
  • Back button control in windows phone app
  • Get matching enum int values from list of strings
  • Ajax Control Toolkit AutoCompleteExtender displays html source character by character of the current page as autocomplet
  • How to select a node with namespace from XmlDocument?
  • multiple foreach loops inside while loop
  • Why does setting a MinimumSize break the table layout?
  • WatIn SelectList().SelectByValue() return error Run script failed
  • SignalR not works on Google Chrome
  • Sync sent mail with Sent folder
  • return a View and File in a single method in ASP.Net MVC
  • FastReport mvc GetParameter() returns null
  • How to check datatable select method returns datatable c#
  • How to sort an array based on the occurrences of the elements in a string in C#?
  • App crashes without throwing any exception in windows phone 8.1 xaml
  • How to get values from command argument from gridview on link button's click?
  • What's the proper way to convert a Vector3DF into byte array?
  • Is there a way to place a default image for control in edit/view mode?
  • How to set a click event for button in repeater control
  • how to make communication with two different process in same computer?
  • Which is the best crash logging tool for Windows Phone 8 Apps
  • Custom MarkerStyle in MS Chart Control
  • while opening the page getting error there is no row at position 0
  • Error message in Monogame: Unhandled Exception: System.DllNotFoundException: SDL2.dll
  • How to extract "Message" part from Google API error message
  • Receiving Gigs of data from Mobile Service on UpdateAsync method
  • Can't figure out what this is? Unrecognized escape sequence (Mono)
  • Calling stored procedure from another stored procedure with parameters
  • Bind Strings from an .resw file with ReswFileCodeGenerator in XAML
  • wpf DataGrid column index is not saved
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org