Xamarin: How to keep persistent data with Observable collection?

Dsto 1 Reputation point
2020-12-08T21:40:06.827+00:00

Hi All,

I am using a simple Observable Collection to store list entries in my notepad app. I have ICommands to add and remove entries from the List.

public ObservableCollection<string> ListItem { get; set; }
       public string Items { get; set; }
         public MainPageViewModel()
       {
           ListItem = new ObservableCollection<string>();           
       }

At the moment, Items that I add to the list do not persist after closing the app. I can add an item to the list, but when I close and reopen the app, the list is empty.
I would like for the entries that are held in the List ( the Observable Collection) to remain between sessions.
So far I can add and delete from the list, but nothing is persistent.

Thanks

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,301 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Alessandro Caliaro 4,181 Reputation points
    2020-12-08T21:43:35.457+00:00

    Use a database, a file, Xamarin Essentials Preferences