locked
App Settings RRS feed

  • Question

  • I'm a beginner programmer, so I don't know how to make settings for my app. I want to settings to be able to save and be there every time the user opens and closes the file. How do I do this, and how can I change the settings from withing the app? Thanks!
    Sunday, October 13, 2013 11:20 PM

Answers

  • We can use LocalSettings for storing and retrieving the user settings inside the app. Further in case you do not have large setting values, you can go for RoamingSettings which will be available for user on any device he connects through. 

    For more details see ApplicationData class


    Thanks, Sachin

    • Proposed as answer by Dave SmitsMVP Monday, October 14, 2013 6:04 PM
    • Marked as answer by Young Genius Wednesday, October 16, 2013 3:48 AM
    Monday, October 14, 2013 3:39 PM

All replies

  • Hi ,

    The best solution for your app is to create and use sqlite database. You have then in control completely your application. I have a settings table in my app where I'm keeping user name , passwords etc.

     

    You can design and create tables where you can keep your settings and have them used inside the code. The most important is to decide what you want to keep in there and then design it as a database table.

    Also if you have time you can create a database table and keep you alert messages . Giving them unique coding and then let your app to do the rest.

    If you are a new programmer my solution is pretty difficult because you are diving in the deep . But is the best.

    There isn't any easy way. And this is the only way if you want to create something nice.

    So I would suggest to start with the below links

    http://code.msdn.microsoft.com/windowsapps/Windows-8-Modern-Style-App-Samples

    http://code.msdn.microsoft.com/windowsapps/Using-SQLite-and-sqlite-79efa172

    http://code.msdn.microsoft.com/windowsapps/Using-SQLite-Asynchronously-b8372137Be patient , read carefully and follow instructions and you will be OK.

    thank you

    Monday, October 14, 2013 5:06 AM
  • We can use LocalSettings for storing and retrieving the user settings inside the app. Further in case you do not have large setting values, you can go for RoamingSettings which will be available for user on any device he connects through. 

    For more details see ApplicationData class


    Thanks, Sachin

    • Proposed as answer by Dave SmitsMVP Monday, October 14, 2013 6:04 PM
    • Marked as answer by Young Genius Wednesday, October 16, 2013 3:48 AM
    Monday, October 14, 2013 3:39 PM
  • Thanks! You both helped a lot!
    Wednesday, October 16, 2013 3:49 AM
  •  public static void SaveSettings(string key, string value)
            {
                try
                {
                    var applicationData = Windows.Storage.ApplicationData.Current;
                    applicationData.LocalSettings.Values[key] = value;                 
                }
                catch
                {
                }
            }
            public static string RetrieveSettings(string key)
            {
                string result = null;
                try
                {
                    var applicationData = Windows.Storage.ApplicationData.Current;
                    if (applicationData.LocalSettings.Values[key] != null)
                        result = applicationData.LocalSettings.Values[key].ToString();
                }
                catch
                {
                     result = null;
                }
                return result;
            }
    SaveSettings("accessToken", accessToken);
    string accessToken = RetrieveSettings("accessToken");

    simple if its answer mark as answer and vote it

    or

    go to app.xaml

    <x:String x:Key="URLLOGO">http://10.0.0.54/analyzr2.0/logo/</x:String>
    

    in all pages do this

    string LOGOURL = (string)(App.Current.Resources["URLLOGO"]);

    • Proposed as answer by prasanas Wednesday, October 16, 2013 10:37 AM
    Wednesday, October 16, 2013 7:25 AM