SecureStorage and Preference between Class and App

Jassim Al Rahma 1,566 Reputation points
2022-08-30T13:55:58.07+00:00

Hi,

I have a MAUI Class Library where I set a SecureStorage value:

SecureStorage.SetAsync("TempStorage", "My Name is Jassim");  

but when I try to read it in my MAUI App:

DisplayAlert("TempStorage", SecureStorage.GetAsync("TempStorage").Result, "Ok");  

It does not show any value..

Is it because of a different namespace? How to solve it?

Kindly advise..
Jassim

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,412 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 74,491 Reputation points Microsoft Vendor
    2022-08-31T08:31:30.113+00:00

    Hello,

    Is it because of a different namespace?

    Yes, due to different namespaces, MAUI will create different filename of [YOUR-APP-PACKAGE-ID].xamarinessentials. files(Encryption keys are stored in KeyStore and encrypted data is stored in a named shared preference container).

    How to solve it?

    You can create 1[web service] to store these information. Please see this document: Consume a REST-based web service - .NET MAUI | Microsoft Learn

    Best Regards,

    Leon Lu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.