locked
Application.Current.Properties dont work in Xamarin 2.0 RRS feed

  • Question

  • User17181 posted

    Hi! Today I have updated my project and Application.Current.Properties dont work correctly. I could save value and read it while my app running, but is i stop and run agarin, Application.Current.Properties is empty. Thank you for help.

    Wednesday, November 18, 2015 10:00 AM

Answers

  • User174493 posted

    Hi! I had the same issue, it worked fine until the upgrade to Xamarin 4 and Forms 2.

    I've solved in this way: Application myApp = Application.Current; bool check = myApp.Properties.ContainsKey(key);

    Don't know why, but splitting Application.Current.Properties in two parts works!

    Stefano

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Wednesday, November 18, 2015 9:52 PM

All replies

  • User174493 posted

    Hi! I had the same issue, it worked fine until the upgrade to Xamarin 4 and Forms 2.

    I've solved in this way: Application myApp = Application.Current; bool check = myApp.Properties.ContainsKey(key);

    Don't know why, but splitting Application.Current.Properties in two parts works!

    Stefano

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Wednesday, November 18, 2015 9:52 PM
  • User174593 posted

    Hi! I have the same issue. The solution of Stefano does NOT work for me, any other ideas? Thanks! Karsten

    Thursday, November 19, 2015 8:29 AM
  • User2773 posted

    Did you try to do forced save?

    await Application.Current.SavePropertiesAsync();

    Thursday, November 19, 2015 4:30 PM
  • User63795 posted

    I have noticed the same issue. In XF versions prior to 2.0, the settings saved in Application.Current.Properties would survive a swipe up to clear the app from memory. Now they do not. Waiting to hear if this is intentional or not.

    Thursday, November 19, 2015 6:33 PM
  • User17181 posted

    Hi everyone. Thank you for the messages. I started to use https://github.com/jamesmontemagno/Xamarin.Plugins/tree/master/Settings. It works fine with xf updates and it is simple in use.

    Thursday, November 19, 2015 6:43 PM
  • User171101 posted

    Anyone know if this is intentional or a bug in the current version ?

    Friday, November 20, 2015 4:28 PM
  • User162453 posted

    @deandean @karbo @EricSchmitz Are you seeing this on a specific platform (iOS, Android, Windows) or is it common to all platforms?

    Wednesday, November 25, 2015 9:35 PM
  • User63795 posted

    I noticed it in iOS and did not test the behavior on the Android side. I have since refactored the code to use Montemagno's Settings plugin.

    Wednesday, November 25, 2015 10:39 PM
  • User77514 posted

    I have this issue too in android platform.It is caused by Xamarin.Android 4.0 but not Forms 2.0

    Thursday, November 26, 2015 12:35 AM
  • User6391 posted

    I have this happening on XF2 even on a very fresh app.

    protected override void OnStart()
    {
       if (!Current.Properties.ContainsKey ("key")) {
           Current.Properties.Add("key", "test");
           // was not using SavePropertiesAsync with 1.4x and would still work just fine
           SavePropertiesAsync ();
       }
       else
           Debug.WriteLine("Found");
    }
    

    Will never find anything. Was working fine before the upgrade.

    Test is done launching app from VS on iOS Simulator (Mac), if that's of any help

    Thursday, November 26, 2015 10:33 AM
  • User174593 posted

    I had the issue on android, did not test the other platforms. Going back to Forms 1.5 didn't help, so now I use the settings-plugin from jamesmontemagno. Works fine.

    Thursday, November 26, 2015 2:00 PM
  • User43611 posted

    @karbo said: I had the issue on android, did not test the other platforms. Going back to Forms 1.5 didn't help, so now I use the settings-plugin from jamesmontemagno. Works fine.

    I had to do the same to get Properties to persist - built in mechanism didn't work, used James plugin in the end to get it saving...

    Friday, November 27, 2015 12:15 AM
  • User162453 posted

    We're still looking into this issue, but in the meantime this workaround might address the problem for some applications: https://forums.xamarin.com/discussion/comment/169577/#Comment_169577

    Monday, December 7, 2015 11:49 PM
  • User167070 posted

    I am having the issue in my Xamarin Forms project on Android devices.

    I can save and access data in Application.Current.Properties in debug mode but it fails in release mode.

    Monday, December 14, 2015 11:44 AM
  • User156380 posted

    Fails for me in Android Debug as well.

    Tuesday, January 26, 2016 9:43 PM
  • User218724 posted

    Application.Current.SavePropertiesAsync() not working, gives error missing assembly reference of SavePropertiesAsync, and not saving my data into apllication.cureent.properties []; any solution?

    Wednesday, April 27, 2016 4:44 PM
  • User28549 posted

    I ended up having to revert to @JamesMontemagno's settings plugin (didn't feel like writing it myself). Happening on Android when the app is killed and restarted.

    Wednesday, April 27, 2016 5:16 PM