Save User Settings with the Xamarin.Essentials Preferences API

Поділитися
Вставка
  • Опубліковано 12 жов 2024

КОМЕНТАРІ • 80

  • @epicgrapefruit7563
    @epicgrapefruit7563 3 роки тому +1

    Thanks straight to the point, worked without any hassle.

    • @jfversluis
      @jfversluis  3 роки тому

      Boom! That's the way it's supposed to be! Thanks for letting me know!

  • @3ammin9
    @3ammin9 2 роки тому

    Thanks for the video Gerald!
    Are these preferences hidden away from other apps? E.g. If I use a file manager, would I be able to say, navigate to the file where the preferences are saved, open it up in a text editor, and view the preference contents?
    Or are other apps unable to access and view these preferences?

  • @andrewtruckle1695
    @andrewtruckle1695 3 роки тому +1

    What a neat feature. Just what I needed! 😊 Is it worth covering the "binding" approach to the preferences via xaml too? Thanks! 👍

    • @jfversluis
      @jfversluis  3 роки тому +1

      Shouldn’t be different than to binding anything else

    • @andrewtruckle1695
      @andrewtruckle1695 3 роки тому

      @@jfversluis I got this working. It has helped a lot. My problem now is that I have to use TabbedPage and not TabView because TabView does not work on MacOS. Whilst I have access to the settings the user selected on page 1 I do not have access to the underlying "data" that page 1 model loaded up from xml.

    • @andrewtruckle1695
      @andrewtruckle1695 3 роки тому

      Resolved the issue with accessing model data from different pages. I followed your MessagingCenter tutorial. Ever so helpful. Awesome! :)

  • @trendsonly
    @trendsonly 3 роки тому

    Just what I was looking for Thanks!

    • @jfversluis
      @jfversluis  3 роки тому

      Perfect! Glad to be of service!

  • @drivetrainerYT
    @drivetrainerYT 2 роки тому

    Very helpful channel, definitely subbed

  • @PrinterGLB
    @PrinterGLB Рік тому

    Thank you. Every video has helped me a lot.😊

  • @develofer6395
    @develofer6395 3 роки тому

    Great video bro! well explained, thank you so much.

  • @solvedplus858
    @solvedplus858 10 місяців тому

    great tutorial
    many thanks

  • @LeoBranca-y8o
    @LeoBranca-y8o 3 роки тому

    Great feature. Nice explanation. Is there a size limit to store (kb)?

    • @jfversluis
      @jfversluis  3 роки тому

      I don’t think so, but it’s not the fastest way to store data so I would keep it small and simple, else look at other solutions

  • @alisaleem2381
    @alisaleem2381 4 роки тому +1

    Thanks this really helped me a lot..
    As a newbie im also confused about UI design in Xamarin Forms,
    Confusion 1.
    (sorry if this is a bad question)
    Q1. In flutter we could use media query statement to get device's screen width and height and store it in some var and then design our ui according to that value or we had percentage system.
    Can i use percentages in Xamarin Forms? For example can i use 20% as width in Box view instead of like 200 px.
    Q2. Do we really need to get screen width or height for responsive ui?
    Confusion2:
    I know there is an api for getting device info in Xamarin Essential but dont know how to implement it in my app since i could not understand the docs.
    Can you elaborate this api in one of your upcoming vid?
    Just checked your vid on device display info and worked for me thanks
    im sorry if i am asking too much.
    Thank you again this vid was really helpful.

    • @jfversluis
      @jfversluis  4 роки тому +1

      Glad to see it was helpful! There are no bad questions, so don't worry! :)
      Q1: that kind of depends on what you're doing and how. As far as I know we don't have something like the media query you mentioned. There might be something like that when you're using CSS (yes, you can use CSS!). Anyway, with a Grid for instance you can make relative rows and columns with percentages or use the FlexLayout to make it wrap to your needs. There are a lot of resources here: www.google.com/search?q=xamarin.forms+responsive+design
      Q2: that depends on how you want to solve it. But you certainly can! :)
      Device Info. Absolutely! I think I can do that this week or maybe next! Anything specific you are looking for?

    • @alisaleem2381
      @alisaleem2381 3 роки тому +1

      @@jfversluis thank you for your response.
      That Css thing was new to me and since I have a little background with css that really broaden my options!
      Thanks you.

    • @jfversluis
      @jfversluis  3 роки тому +1

      @@alisaleem2381 Awesome! Let me know how it goes :)

  • @juliferdjourney
    @juliferdjourney 4 роки тому +1

    thank you bro for this...

  • @julianberger234
    @julianberger234 3 роки тому

    Hey! Thanks for this video, probably exactly what I am looking for.
    But I am wondering if there is a better way for my problem. I want to build an app that has a list of questions with dropdown menus behind them that show values from 1 to 5. Now I want my users to be able to answer these questions and close the app after that and continue at a later time. My idea is to store these values for every question in the preferences and load them at the beginning. Is this a good way to solve this, or are there better ways?
    Thank you for your help!

    • @jfversluis
      @jfversluis  3 роки тому +2

      Glad that you liked it!
      If it's just a handful of questions with simple types as answers then I guess the preferences are definitely enough. There is no one right way of doing things, if this works for you at the moment, then thats great and it is a good solution! Whenever you have new requirements, go look for something a bit more advanced :)

  • @amigoSeiya
    @amigoSeiya 3 роки тому

    Hi Gerald! Great video! I have two questions: Is it possible to share the preferences stored on my device with another device? Like, using a Share button. For example, I configure some setting to make a connection to a web service and I have a bunch of phones that need this exact configuration. The second question is: Is there any way to transition from Dictionaries to Preferences, without user interaction? Thanks a lot for your help.!

    • @jfversluis
      @jfversluis  3 роки тому +1

      Sure :) I am showing this with a UI, but you can do all of this programmatically without any user interaction

    • @amigoSeiya
      @amigoSeiya 3 роки тому

      @@jfversluis thanks Gerald. How about exporting the preferences to another phone? Let’s say for example, I have some connection settings on my iPhone and I want to share said settings to an android phone. Is that possible? Do you have some kind of example? I have searched all over the web with no luck. Thanks!

    • @jfversluis
      @jfversluis  3 роки тому +1

      @@amigoSeiya I mean, the preferences are nothing more than any other piece of data you send or receive to and from a server :) serialize to json, save on your server and when requested on another phone Android or iOS or something else, serialize to json, get it in the phone, deserialize and save as preferences.

    • @amigoSeiya
      @amigoSeiya 3 роки тому

      @@jfversluis sorry, sometimes I’m really bad at explaining things haha. I want to share the preferences locally. Let’s say for example using Airdrop or even WhatsApp, no server involved 😃

    • @jfversluis
      @jfversluis  3 роки тому +1

      Aah gotcha! No worries :) I guess you could. Not sure if that would be the best user experience though

  • @m.m4051
    @m.m4051 2 роки тому

    good video! i'm wondering if i can use this in xamarin.android project only??

    • @jfversluis
      @jfversluis  2 роки тому +1

      You can definitely use this without Forms as well :)

  • @демидвладимиров-в3р
    @демидвладимиров-в3р 9 місяців тому

    thanks thaks thaks!!!!!!!!!

  • @matt-i3r6w
    @matt-i3r6w 3 роки тому

    I want to save user data & settings to the cloud, with possibly to edit them. Can I use Firebase database or would Firestore be better? Can you make a video about it?

    • @jfversluis
      @jfversluis  3 роки тому

      You definitely can! Whether Firebase database or Firestore is better depends on your requirements :)

  • @SalimAlmoslim
    @SalimAlmoslim 2 роки тому

    Thanks for this video :-)

    • @jfversluis
      @jfversluis  2 роки тому

      You’re very welcome Salim!

  • @reyanthonyflores
    @reyanthonyflores 3 роки тому

    Can this also be used for login session or are there other options?

    • @jfversluis
      @jfversluis  3 роки тому +1

      Then you probably want to look into the secure storage :)

  • @andrewtruckle1695
    @andrewtruckle1695 3 роки тому

    The automatic intellises created private const variables at the top of my xaml page: private const string PrefNumberMonths = "NumberMonths";. Nothing wrong with that but it means I have to replicate these same keys in the other pages that also use the preferences. Is there a better solution? 🧐

    • @jfversluis
      @jfversluis  3 роки тому

      Place them somewhere else and not make them private? :D IntelliSense is just suggesting, not the law

  • @SrEnrikitooo
    @SrEnrikitooo Рік тому

    Hiii, can you save an array of strings??

    • @jfversluis
      @jfversluis  Рік тому

      Preferably not. This is only for simple types. Anything else you can still convert to a string but performance will probably be horrible

  • @viktordobudko4735
    @viktordobudko4735 2 роки тому +1

    can i send this data to another page?

    • @jfversluis
      @jfversluis  2 роки тому

      Absolutely why not?

    • @viktordobudko4735
      @viktordobudko4735 2 роки тому

      @@jfversluis I don't really understand how this can be done. I have 3 windows: Registration, Login and Calculator. On the first launch of the application, the Registration page opens with the fields: username and password; and the register button. On the second launch, the Login page should already appear. In this case, how can the saved data be transferred from the Registration page to the Login page?

  • @anassnassim
    @anassnassim 3 роки тому +1

    thanks for that
    can you share with us a custom renderer of tab view

    • @jfversluis
      @jfversluis  3 роки тому +1

      What do you want to do with the tabs?

    • @anassnassim
      @anassnassim 3 роки тому

      @@jfversluis thank you for your replay I appreciate
      i just need to do the same design with xamarin forms for ios and android like this
      ibb.co/nm2x7B5

    • @jfversluis
      @jfversluis  3 роки тому +1

      Ah gotcha! Then you probably don't want to use custom renderers but render the tabview entirely. Have a look at this: github.com/jsuarezruiz/Xamarin.Forms.TabView

    • @anassnassim
      @anassnassim 3 роки тому

      @@jfversluis thank you I have two questions and I am sorry if I bothering you
      1- how I can add a corner radius to it?
      2- how I can add the effect of the circle in the selected one?

    • @jfversluis
      @jfversluis  3 роки тому +1

      You're never bothering me. Don't worry :)
      Unfortunately I don't know the answers to that. I haven't really implemented it yet myself. But I think there is a lot possible with that control. How about you find out and let me know? ;)

  • @thomasdevelopment
    @thomasdevelopment Рік тому

    I have this running on maui and working but am Trying to build unit tests in an Xunit project and running into "This functionality is not implemented in the portable version of this assembly." Does anyone know how to either mock Preferences or just get it to work in unit test?

    • @jfversluis
      @jfversluis  Рік тому

      You’ll probably want to wrap it in some kind of service and mock it

    • @thomasdevelopment
      @thomasdevelopment Рік тому

      @@jfversluis I love how responsive you are. I commend your commitment. Ive tried mocking it using FakeItEasy mocking framework by stating if its called then give a specific return but it still throughs the referencing error.

    • @thomasdevelopment
      @thomasdevelopment Рік тому

      @@jfversluis as a side note. Ive seen your maui unit testing video where you setup the project correctly but you should do a video creating some tests. Ive looked around and for Maui or Xamarin theres not a lot of quality out there.

  • @sheikhshuaib8451
    @sheikhshuaib8451 3 роки тому

    how to loop through all the preferences or any other method to do that

    • @jfversluis
      @jfversluis  3 роки тому +1

      I don't think there is a way to do that right now

    • @sheikhshuaib8451
      @sheikhshuaib8451 3 роки тому

      @@jfversluis what about Setting plugin

    • @jfversluis
      @jfversluis  3 роки тому

      What do you want to know? I think that uses the same thing because that is the old plug-in this is based on. That means; you also can’t iterate over that

  • @AMIRKHAN-dm2fm
    @AMIRKHAN-dm2fm 4 роки тому +1

    Please Please sir make a tutorial on in-app update in app center .

    • @jfversluis
      @jfversluis  4 роки тому +1

      I must admit I never used that myself! But I will look into it :)

    • @AMIRKHAN-dm2fm
      @AMIRKHAN-dm2fm 4 роки тому

      @@jfversluis ok just confirm me that in-app update is possible or not with app center?

    • @jfversluis
      @jfversluis  4 роки тому

      @@AMIRKHAN-dm2fm It is definitely possible! See: docs.microsoft.com/appcenter/distribution/inappupdates

  • @LinhTran-km9zw
    @LinhTran-km9zw 3 роки тому

    How to save DatePickers/TimePickers data??Pls help me.

    • @jfversluis
      @jfversluis  3 роки тому

      What do you want to save from it?

  • @sandeepreddypalannagari8489
    @sandeepreddypalannagari8489 2 роки тому

    sir for me app is crashing if I (Preferences.Get) in the comment then it working sir

    • @jfversluis
      @jfversluis  2 роки тому +1

      That can be because of a lot of reasons. So it’s kind of hard to say something useful about it. It should work :)

    • @sandeepreddypalannagari8489
      @sandeepreddypalannagari8489 2 роки тому

      @@jfversluis ok sir.

    • @sandeepreddypalannagari8489
      @sandeepreddypalannagari8489 2 роки тому

      @@jfversluissir sorry my code is wrongly redirecting. your code is working

    • @jfversluis
      @jfversluis  2 роки тому

      Glad you figured it out!