How store user credentials android in account store

Hi All, How can I store user credentials in account stor..for android i am using c# xamarin. I have see this link ( https://developer.xamarin.com/recipes/cross-platform/xamarin-forms/general/store-credentials/ ) but i do not understand what is means.

Posts

  • MaybeLouisMaybeLouis MYMember

    Did anyone have a sample source code for android c#??

  • JFMGJFMG DEMember ✭✭

    Hi MaybeLouis,

    Which part of the documentation didn't you understand?

    In this example I try to get a UUID for the service ID "DeviceUuid". If it is not available, I create a UUID and save it:

    public string GetDeviceUuid()
    {
        var accountStore = AccountStore.Create();
        var uuidKey = "DeviceUuid";
    
        // Find value for uuidKey. FirstOrDefault returns null, if nothing was found
        var account = accountStore.FindAccountsForService(uuidKey).FirstOrDefault();
    
        if (account != null && account.Properties != null && account.Properties.ContainsKey(uuidKey))
            return account.Properties[uuidKey];
    
        // If nothing was returned until here, there was no UUID, so we create a new one
        var uuid = Guid.NewGuid().ToString();
    
        // Now we save the UUID to the Account Store
        account = new Account();
        account.Properties.Add(uuidKey, uuid);
        accountStore.Save(account, uuidKey);
    
        return uuid;
    }
    
Sign In or Register to comment.