Migrate SQLite db from Xamarin Android to NET Maui app?

BKS 20 Reputation points
2024-05-02T02:26:31.5566667+00:00

I am having issue with one of my app migration to .NET MAUI. When I migrate, I am unable to access SQLlite databse which was being used in Xamarin

in XAMARIN database was being accessed as follow:

https://learn.microsoft.com/en-us/previous-versions/xamarin/get-started/quickstarts/database?pivots=windows

public static string DatabasePath => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), DatabaseFilename);

not sure how to access this in .NET MAUI.

https://learn.microsoft.com/en-us/dotnet/maui/data-cloud/database-sqlite?view=net-maui-8.0

I have been trying using following method but was unsuccessful.

In .NET MAUI

public static string DatabasePath => Path.Combine(FileSystem.AppDataDirectory, DatabaseFilename);

Would appreciate any help?

Thanks

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

1 answer

Sort by: Most helpful
  1. BKS 20 Reputation points
    2024-05-02T19:50:51.9733333+00:00

    Fixed this issue by using the following path in MAUI again

    Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),