Skip to content

Android: SecureStorage Adding a value after calling RemoveAll() will not persist the value #19983

@phillippschmedt

Description

@phillippschmedt

Description

When I call Microsoft.Maui.Storage.SecureStorage.Default.RemoveAll() and then add a value, the value will disappear when restarting the app. Adding a value after restart will then again persist it properly.

Steps to Reproduce

Start Android App
Call Microsoft.Maui.Storage.SecureStorage.Default.RemoveAll();
Call: Microsoft.Maui.Storage.SecureStorage.Default.SetAsync(key, value)
Call: Microsoft.Maui.Storage.SecureStorage.Default.GetAsync(key) -> Returns the value
Restart App
Call: Microsoft.Maui.Storage.SecureStorage.Default.GetAsync(key) -> Value is gone
Call: Microsoft.Maui.Storage.SecureStorage.Default.SetAsync(key, value)
Call: Microsoft.Maui.Storage.SecureStorage.Default.GetAsync(key) -> Returns the value
Restart App:
Call: Microsoft.Maui.Storage.SecureStorage.Default.GetAsync(key) -> Returns the value

My conclusion is, that calling RemoveAll() will somehow break the SecureStorage until next app start

Link to public reproduction project repository

https://github.com/phillippschmedt/SecureStorageIssue (see MainPage.xaml.cs, use debugger to inspect)

Version with bug

8.0.6

Is this a regression from previous behavior?

Yes, this used to work in Xamarin.Forms

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Tested on Android 13

Did you find any workaround?

Not yet

Relevant log output

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions